Securing Higher Grades Costing Your Pocket? Book Your Coursework Help at The Lowest Price Now!

  • +1-617-874-1011 (US)
  • +44-117-230-1145 (UK)
Online Customer Service

Operating System Assignment 2

Exercise 3

  1. Using the program shown in Figure 3.30, explain what the output will be at Line A.
  • The output of this program will be 5 al line A. Because the child process updates only its copy of value and it returns that value to the parent process which is 5.
  1. Including the initial parent process, how many processes are created by the program shown in Figure 3.31?
  • In this program fork() function called three times, and whenever a fork() function called, it will create child nodes process of a binary tree. So, there are 8 process created here.
  1. Original versions of Apple’s mobile iOS operating system provided no means of concurrent processing. Discuss three major complications that concurrent processing adds to an operating system.
  • Switching from one process to another process leads to time overhead this requires storing the current register values and loading the register values of the next process from its program Control Block.
  • The OS must keep track of the main memory address space allocated to each process so that a process does not affect or harm other processes data.
  • If a running process requires large space in memory, then other process needs to be dumped back to hard disk which again leads to time overhead.
  1. When a process creates a new process using the fork() operation, whichof the following states is shared between the parent process and the child process?
    1. Stack
    2. Heap
    3. Shared memory segments
  • Shared memory segments. When a process uses the fork() to create a new process, all the new processes corresponding to the parent process are created and loaded into a separate memory location for the child process by the operating system. Only the shared memory segments are shared between the parent process and the newly forked child process.

Exercise 4

  1. Provide two programming examples in which multithreading provides better performance than a single-threaded solution.
  2. In GUI, different threads are executed for the multiple task. Such as to fix the bugs, for the execution of the program and for the better performance of the program.
  3. In a web server, number of users request for the application. Therefore, number of different threads are executed for different users.
  1. Describe the actions taken by a kernel to context-switch between kernel level threads.
  • Kernel is the head of any OS. And several threads are executed by the kernel with different tasks. Also, interrupts of multi threads are control but kernel.
  • For the kernel, the execution time is the main issue.
  • Context switching between kernel threads typically requires saving the value of the CPU registers from the thread being switched out and restoring the CPU registers of the new thread being scheduled.
  1. Provide two programming examples in which multithreading does not provide better performance than a single-threaded solution.
  2. Any kind of sequential program is not a good candidate to be threaded. An example programs like this are sorting numbers, computing the factorial of a number, and minimize the linear equation which gives better performance if it uses the single thread.
  3. Another example is a "shell" program such as the C-shell or Korn shell. The shell programs use the single thread to execute the program.

Exercise 5

  1. Explain why Windows, Linux, and Solaris implement multiple locking mechanisms. Describe the circumstances under which they use spinlocks, mutex locks, semaphores, adaptive mutex locks, and condition variables. In each case, explain why the mechanism is needed.
  • These operating systems provide different locking mechanisms depending on the application developers' needs.
  • Spin locks are useful for multiprocessor systems where a thread can run in a busy-loop, for a short period of time, rather than incurring the overhead of being put in a sleep queue.
  • Mutexes are useful for locking resources. Solaris 2 uses adaptive mutexes, meaning that the mutex is implemented with a spin lock on multiprocessor machines.
  • Semaphores and condition variables are more appropriate tools for synchronization when a resource must be held for a long period of time, since spinning is inefficient for a long duration.
  1. What is the meaning of the term busy waiting? What other kinds of waiting are there in an operating system? Can busy waiting be avoided altogether? Explain your answer.
  • Busy waiting means that a process is waiting for a condition to be satisfied in a tight loop without relinquishing the processor. It checks the act of CPU for the critical section entry.
  • Busy waiting can be overcome by a wait() and signal() semaphore operation.
  • A process could wait by relinquishing the processor, and block on a condition and wait to be awakened at some appropriate time in the future.
  • Busy waiting can be avoided but incurs the overhead associated with putting a process to sleep and having to wake it up when the appropriate program state is reached.
  1. The first known correct software solution to the critical-section problem for two processes was developed by Dekker. The two processes, P0 and P1, share the following variables:

boolean flag[2]; /* initially false */

int turn;

The structure of process Pi (i == 0 or 1) is shown in Figure 5.21. The other process is Pj (j == 1 or 0). Prove that the algorithm satisfies all three requirements for the critical-section problem.

  • Mutual exclusion is ensured using the flag and turn variables. If both processes set their flag to true, only the process whose turn it will succeed. The waiting process can only enter its critical section when the other process updates the value of turn.
  • Progress is provided through the flag and turn variables. If the process tries to access the critical section, it can set their flag variable to true and enter their critical section. The next time process try to enter its critical section, it repeats the process of entering its critical section and setting turn to the other process upon exiting.
  • Bounded waiting is preserved using the turn variable. Suppose two processes wants to enter to their respective critical sections. They both set their value of flag to true. But only the thread whose turn it is can proceed and the other thread waits. If bounded waiting were not preserved, it would therefore be possible that the waiting process would have to wait indefinitely while the first process repeatedly entered its critical section.


  • 24 x 7 Availability.
  • Trained and Certified Experts.
  • Deadline Guaranteed.
  • Plagiarism Free.
  • Privacy Guaranteed.
  • Free download.
  • Online help for all project.
  • Homework Help Services


Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak: Sheryl. Read More

Tap to Chat
Get Instant Assignment Help
Tap to Chat
Get Instant Assignment Help