Question

In: Computer Science

Could you include little explanation. What is a system call to replace the process image? If...

Could you include little explanation.

What is a system call to replace the process image? If successful, what is its effect on the process that calls it?

When scheduling processes, provide an example of how round-robin which is known as one of the fairer systems, can be unfair on a multi-user system.

What is the difference between a semaphore and mutex? When would you use one over the other?

Solutions

Expert Solution

1. The exec() family of functions replaces the current process image with a new process image. It loads the program into the current process space and runs it from the entry point.This act is also referred to as an overlay.As a new process is not created, the process identifier (PID) does not change, but the machine code, data, heap, and stack of the process are replaced by those of the new program.

A successful overlay destroys the previous memory address space of the process, and all its memory areas, that were not shared, are reclaimed by the operating system. Consequently, all its data that were not passed to the new program, or otherwise saved, become lost.

A successful exec replaces the current process image, so it cannot return anything to the program that made the call i.e. the exec system calls do not return to the invoking program as the calling image is lost. Processes do have an exit status, but that value is collected by the parent process.

If an exec function does return to the calling program, an error occurs, the return value is −1, and errno is set to one of the following values:

E2BIG-The argument list exceeds the system limit.

EACCES-The specified file has a locking or sharing violation.

ENOENT-The file or path name not found.

ENOMEM-Not enough memory is available to execute the new process image.

2. The round-robin (RR) scheduling algorithm is similar to FCFS scheduling, but preemption is added to enable the system to switch between processes.A small unit of time, called a time quantum or time slice, is defined. A time quantum is generally from 10 to 100 milliseconds in length. The ready queue is treated as a circular queue. The CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval of up to 1 time quantum.To implement RR scheduling, we again treat the ready queue as a FIFO queue of processes. New processes are added to the tail of the ready queue.The CPU scheduler picks the first process from the ready queue, sets a timer to interrupt after 1 time quantum, and dispatches the process.

Let us consider an example of a multi user system where round robin is implemented.There are 6 processes with id, burst time and arrival time as shown below –

PID ARRIVAL TIME BURST TIME
P1 0 4
P2 1 5
P3 2 2
P4 3 1
P5 4 6
P6 6 3


We consider a time quantum of 2 units and calculate average waiting time, completion time, turn around time for each processes’s execution.The arrival times are different as this is a multi user system and process can arrive at any time from any user.

The execution can be represented as the following Gantt Chart.

P1 P2 P3 P1 P4 P5 P2 P6 P5 P2 P6 P5

0 2 4 6 8 9 11 13 15 17 18 19 21

At the arrival time = 0, CPU scheduler picks up the p1 process from the ready queue and it will run per 2 unit of time according to given time quantum. At arrival time = 2, there are 3 processes available P1, P2 & P3. Executed process will be placed at the tail of the ready queue. Scheduler will select the next process from the ready queue. So, P2 will execute first. After the execution of P2 process, P3 will be the next the process in the queue. So, P3 will complete execution.
According to the context switch every executed process will be placed at the tail of the ready queue and get a chance for execution again according to each position.
Every process will follow the same procedure. It is good practice to make a separate queue and place the process executed process at the tail of the queue. So, it will be easy to understand the next process which is going to be executed.

Completion time:
P1 = 8,
P2 = 18,
P3 = 6,
P4 = 9,
P5 = 21,
P6 = 19

Turn Around time:
P1 = 8 – 0 = 8,
P2 = 18 -1 = 17,
P3 = 6 – 2 = 4,
P4 = 9 – 3 = 6,
P5 = 21 – 4 = 17,
P6 = 19 – 6 = 13

Waiting time:
P1 = 8 – 4 = 4,
P2 = 17 – 5 = 12,
P3 = 4 – 2 = 2,
P4 = 6 – 1 = 5,
P5 = 17 – 6 = 11

Here we see that since on a multi user system processes can arrive at any time therefore the following may occur making the scheduling process unfair :

  • This method spends more time on context switching because of more number of processes coming into the queue.
  • Its performance heavily depends on time quantum.
  • Priorities cannot be set for the processes.
  • If slicing time / time quantum of OS is low, the processor output will be reduced.
  • If the time quantum is increased, the throughput will be decreased.
  • Round-robin scheduling doesn't give special priority to more important tasks.
  • Lower time quantum results in higher the context switching overhead in the system.
  • Finding a correct time quantum is a quite difficult task in this system.

3. The Key Differences Between Semaphore and Mutex are as follows:

  1. Semaphore is a signalling mechanism as wait() and signal() operation performed on semaphore variable indicates whether a process is acquiring the resource or releasing the resource. On the other hands, the mutex(Mutual Exclusion Object) is a locking mechanism, as to acquire a resource, a process needs to lock the mutex object and while releasing a resource process has to unlock mutex object.
  2. Semaphore is typically an integer variable whereas, mutex is an object.
  3. Semaphore allows multiple program threads to access the finite instance of resources. On the other hands, Mutex allows multiple program threads to access a single shared resource but one at a time.
  4. Semaphore variable value can be modified by any process that acquires or releases resource by performing wait() and signal() operation. On the other hands, lock acquired on the mutex object can be released only by the process that has acquired the lock on mutex object.
  5. Semaphore are of two types counting semaphore and binary semaphore which is quite similar to the mutex.
  6. Semaphore variable value is modified by wait() and signal() operation apart from initialization. However, the mute object is locked or unlocked by the process acquiring or releasing the resource.
  7. If all the resources are acquired by the process, and no resource is free then the process desiring to acquire resource performs wait() operation on semaphore variable and blocks itself till the count of semaphore become greater than 0. But if a mutex object is already locked then the process desiring to acquire resource waits and get queued by the system till the resource is released and mutex object gets unlocked.

From above we conclude that Semaphore is a better option when there are multiple instances of resources available. In the case of single shared resource mutex is a better choice.


Related Solutions

Describe the process of convolving an image with a mask (kernel). How could the process be...
Describe the process of convolving an image with a mask (kernel). How could the process be implemented in the (spatial) frequency domain?
If possible, could you write out the process of these problems? include a drawn normal distribution...
If possible, could you write out the process of these problems? include a drawn normal distribution with shading please. 1. suppose X-N (4, 2) what value of x is 1.5 standard deviations to the left of the mean? 2. Suppose X-N (15,3) between what x values does 68.27% of the data lie? The range of x values is centered at the mean the distribution (i.e., 15) 3. X-N (54,8) find the probability that x>56 4. height and weight are two...
Why does the kernel need to validate pointers passed into a system call? What could go...
Why does the kernel need to validate pointers passed into a system call? What could go wrong if it did not validate user pointers?
What explanation does RWMOD provide for why there is no (or little) conditioning of the CS...
What explanation does RWMOD provide for why there is no (or little) conditioning of the CS when CS and US presentations occur at random (how does it explain an organisms sensitivity to contingency)?
When a process executes a "sleep" system call, from the perspective of the process, it simply...
When a process executes a "sleep" system call, from the perspective of the process, it simply pauses for a specified amount of time and then resumes where it left off. Describe, in detail, what a sleep system call looks like from the perspective of the operating system. Regarding system calls: What is a system call? For each of the following system calls, give a condition that would cause it to fail: 1) open; 2) fork; and 3) exec.
A frequent proposal has been to replace the oversight process through a system known as a...
A frequent proposal has been to replace the oversight process through a system known as a “regulatory budget.” Each agency would be assigned a total cost that it could impose on the American economy, and its task would be to select the regulations that best foster the national interest subject to this cost. Can you identify any problems with the regulatory budget approach? How feasible do you believe it would be to calculate the costs of all the regulations of...
As late as 2017, you could purchase a house in Detroit, Michigan, for as little as...
As late as 2017, you could purchase a house in Detroit, Michigan, for as little as $100.Explain how this might be the case, using supply and demand.
PYTHON PLEASE!! ALSO: if you can include an explanation of what the code means that would...
PYTHON PLEASE!! ALSO: if you can include an explanation of what the code means that would be appreciated 8.19 LAB*: Program: Soccer team roster (Dictionaries) This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers and the ratings in a...
what are some elements that could be recommended for the hiring process and what could be...
what are some elements that could be recommended for the hiring process and what could be the legal concerns that should be considered for these elements
Write a little scenario explaining a way that you could commit payroll/HR fraud. Explain what types...
Write a little scenario explaining a way that you could commit payroll/HR fraud. Explain what types of internal controls could prevent that fraud from occurring.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT