<< Chapter < Page Chapter >> Page >

Phase 3 – ipc primitives (semaphores) (10%)

  1. Implement the int CreateSemaphore(char *name, int semval) system call. You will have to update start.s and syscall.h to add the new system call signatures. You will create a container at the systemlevel that can hold upto 10 named semaphores. The CreateSemaphore system callwill return 0 on success and –1 on failure. The CreateSemaphore system call will fail if there are not enough free spots in the container, the name is null, orthe initial semaphore value is less than 0.
  2. Implement int wait(char *name) and int signal(char *name) system calls. Make sure you follow the wait and signal as the mnemonics for these two and not down and up or P and V. The name parameter is the name of the semaphore. Both system calls return 0 onsuccess and –1 on failure. Failure can occur if the user gives an illegal semaphore name (one that has not been created).

Phase 4 –priority scheduling&Simple aging

Required Reading –

  • Thread.h / .cc – The thread class has methods like Yield, Sleep, Finish to manage the scheduling of threads. Understand of this class isessential to proceed.
  • List.h /.cc – Implementation of a Generic Linked List. Understand the importance of the methods of this class clearly especially the SortedRemove&SortedInsert. The ready queue maintained by the scheduler is an object of this type.
  • Scheduler.h / .cc – Implementation of the nachos thread scheduler&dispatcher. You will have to make the majority of your changes in this class.

In this phase you will be implementing a policy that schedules threads depending upon the priority that you set for threads using theExec(char * name, int priority) syscall. The details are as follows -

  • Modify the thread scheduler to always return highest priority thread. You will have to create another parameter in the Thread class– thepriority level of the thread represented by an integer value. The range of thread priorities can be found in thread.h. Provide the appropriate tests inorder to demonstrate the success of your priority scheduling system. Note: Enabling the –rs option for the test programs causes a thread to stop for context switching Yield the CPU to another thread (that could have lower priority) after a given time slice. You might want to have a look at the Thread::Yield() method to take care of this. (7%)
  • Most priority scheduling solutions will starve out a low priority thread. After you complete and test the above part, implement a simple agingsystem to take care of the starvation problem. Under this policy the priority of a thread decreases one unit for every x times the thread is run. That is forevery x thread switches from ready to run, decrement the priority of the high priority threads by 1. Specify x as a constant in your system, with the value -1indicating that aging is disabled. Add thread (“t”) debug statements to display the trace of the aging algorithm. Provide the appropriate tests in order todemonstrate the success of your aging system. (9%)

Phase 5 –putting it all together

  1. Implement a simple shell program to test your new system calls implemented as above. The shell should take a command at a time, and run theappropriate user program. The shell should “Join” on each program “Exec”ed, waiting for the program to exit. On return from the Join, print the exit code ifit is anything other than 0 (normal execution). Also, design the shell such that it can run program in the background. Any command starting with character(&) should run in the background. (Ex:&create will run the test program create program in the background.) (6%)
  2. Solve the Dining Philosopher problem discussed in your text book. Use Semaphore you designed for realizing mutual exclusion and synchronizationamong the philosophers. (8%)

Documentation - Includes internal documentation, and external documentation as described:

  • How did you maintain a list of all processes in the system? What other data structures did you require? (3%)
  • Explain the significance of the Join&Exit system calls. How did you synchronize the 2 syscalls? (4%)
  • What changes did you make to implement Phase 4, and why? (3%)

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




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.

Notification Switch

Would you like to follow the 'Operating systems' conversation and receive update notifications?

Ask