-
Home
- Operating systems
- Projects
- Project 5: multi-programming,
Operation Systems
One-month project
Nachos is currently an uni-programming environment. In
the second project you will design and implement appropriate support formultiprogramming. You will extend the system calls to handle process management
and inter-process communication primitives. In addition you will implement apriority based scheduling and aging mechanism in nachos. You will add this to
the coded first project. Make sure you correct all the deficiencies in yourfirst project before starting the second project.
Phase 1 –memory allocation for multiprogramming: (15%)
Required Reading –
-
Translate.h / .cc – Each object of this class
is a translation of a single virtual page to a physical page.
-
Addrspace.h / .cc – Consists of all data
needed to keep track of executing user programs. The constructor allocatesmemory/pages to processes assuming every virtual address is the same as its
physical address. This restricts us to running one user program at a time. Inthis project we modify the constructor to allow multiple user programs to be run
concurrently.
-
Progtest.cc – The StartProcess function
serves as the starting point of every thread, where the addrspace is created andexecution of the userprogram begins. You might have to create a similar function
to account for new threads that you create.
-
System.h / .cc – All global/system objects
are defined here.
-
Machine.h / .cc - emulates the part of the
machine that executes user programs: main memory, processor registers, etc.
To implement multiprogramming we will have to alter
Nachos so that each process is maintained in its own system thread. We will haveto take care of memory allocation and de-allocation. Here are the
details:
- Add a case in exception handler so that non-system call exceptions
can finish (currentThread>Finish()) the thread. This will be important, as a
run time exception should not cause the operating system to shut down.
- Implement multiprogramming. The code we have given you is
restricted to running one user program at a time. You will need to make somechanges to addrspace.h, and addrspace.cc in order to convert the system from
uniprogramming to multiprogramming. You will need to:
- Come up with a way of allocating physical memory frames so that
multiple programs can be loaded into memory at once.
- Provide a way of copying data to/from the kernel from/to the
user’s virtual address space.
- Properly handling freeing address space when a user program
finishes.
- It is very important to alter the user program loader algorithm
such that it handles memory in terms of pages. Currently, memory spaceallocation assumes that a process is loaded into a contiguous section of memory.
Once multiprogramming is active, memory will no longer appear contiguous innature. If you do not correct the routine, it is most likely that loading
another user program will corrupt the operating system.
Phase 2 –process management: (35%)
- Implement the
SpaceID Exec(char *name, int priority) system call. Exec starts a new user program running within a new
system thread with the given priority. You will need to examine the“StartProcess” function in progtest.cc in order to figure out how to set up user
space inside a system thread. Exec should return –1 on failure, else it shouldreturn the “Process SpaceID” of the user level program it just created. (Note:
SpaceIDs can be kept track of in a similar manner to OpenFileIDs of your project1, except that you will want to keep track of them outside the thread.). For
this phase you can simply ignore the priority.
- Implement the
int Join(SpaceID id) and void Exit(int
exitCode) system calls. Join will wait and block on a “Process
SpaceID” as noted in its parameter. Exit returns an exit code to whomever isdoing a join. The exit code is 0 if a program successfully completes, another
value if there is an error. The exit code parameter is set via the
exitcode parameter. Join returns the exit code for the
process it is blocking on, -1 if the join fails. A user program can only join toprocesses that are directly created by
the Exec system
call . You can not join to other processes or to yourself. You will
have to use semaphores inside your system calls to coordinate Joining andExiting user processes. Also make sure that all processes release the resources
they have been allocated, after they Exit.
Source:
OpenStax, Operating systems. OpenStax CNX. Aug 13, 2009 Download for free at http://cnx.org/content/col10785/1.2
Google Play and the Google Play logo are trademarks of Google Inc.