100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Inter-process communication in operating systems $5.19   Add to cart

Class notes

Inter-process communication in operating systems

 3 views  0 purchase
  • Course
  • Institution

In these notes, Covered all the topics of operating systems briefly. COs - Analyze the structure of OS and basic architectural components involved in OS design. Compare and contrast various CPU scheduling algorithms. Evaluate the requirements for the process synchronization and co-ordinatio...

[Show more]

Preview 3 out of 24  pages

  • December 30, 2022
  • 24
  • 2021/2022
  • Class notes
  • Ymk sir
  • All classes
avatar-seller
3 – IPC

(1) Define following terms.
Race Condition
• Race condition can be defined as situation where two or more processes are reading
or writing some shared data and the final result depends on who runs precisely
when (their relative execution order).
Mutual Exclusion
• It is a way of making sure that if one process is using a shared variable or file; the
other process will be excluded (stopped) from doing the same thing.
Turnaround Time
• Time required to complete execution of process is known as turnaround time.
• Turnaround time = Process finish time – Process arrival time.
Throughput
• Number of processes completed per time unit is called throughput.
Critical Section
• The part of program or code of segment of a process where the shared resource is
accessed is called critical section.
Waiting time
• It is total time duration spent by a process waiting in ready queue.
• Waiting time = Turnaround time – Actual execution time.
Response Time
• It is the time between issuing a command/request and getting output/result.


(2) Explain different mechanisms for achieving mutual exclusion with busy waiting.
Disabling interrupts
• In this mechanism a process disables interrupts before entering the critical section
and enables the interrupt immediately after exiting the critical section.
while( true )
{
< disable interrupts >;
< critical section >;
< enable interrupts >;
< remainder section>; }

1

, 3 – IPC
• Mutual exclusion is achieved because with interrupts disabled, no clock interrupts
can occur.
• The CPU is only switched from process to process as a result of clock or other
interrupts, and with interrupts turned off the CPU will not be switched to another
process.
• Thus, once a process has disabled interrupts, it can examine and update the shared
memory without fear that any other process will intervene.
• This approach is generally unattractive because it is unwise to give user processes
the power to turn off interrupts.
• Suppose that one of them did it and never turned them on again? That could be the
end of the system.
• Furthermore if the system is a multiprocessor, with two or more CPUs, disabling
interrupts affects only the CPU that executed the disable instruction. The other ones
will continue running and can access the shared memory.
• On the other hand, it is frequently convenient for the kernel itself to disable
interrupts for a few instructions while it is updating variables or lists.
• If an interrupt occurred while the list of ready processes, for example, was in an
inconsistent state, race conditions could occur.
• The conclusion is: disabling interrupts is often a useful technique within the
operating system itself but is not appropriate as a general mutual exclusion
mechanism for user processes.


Shared lock variable:
• In this mechanism there is a shared variable lock having value 0 or 1.
• Before entering in to critical region a process check a shared variable lock’s value.
• If the value of lock is 0 then set it to 1 before entering the critical section and enters
into critical section and set it to 0 immediately after leaving the critical section.
While (true)
{
< set shared variable to 1>;
< critical section >;
< set shared variable to 0>;
< remainder section>;
}



2

, 3 – IPC
• If it is 1, means some other process is inside the critical section so, the process
requesting to enter the critical region will have to wait until it becomes zero.
• This mechanism suffers the same problem (race condition). If process P0 sees the
value of lock variable 0 and before it can set it to 1, context switching occurs.
• Now process P1 runs and finds value of lock variable 0, so it sets value to 1, enters
critical region.
• At the same point of time P0 resumes, sets the value of lock variable to 1, enters
critical region.
• Now two processes are in their critical regions accessing the same shared memory,
which violates the mutual exclusion condition.


Strict Alteration:




Process 1 Process 2
• In this proposed solution, the integer variable 'turn' keeps track of whose turn is to
enter the critical section.
• Initially turn=0. Process 1 inspects turn, finds it to be 0, and enters in its critical
section. Process 2 also finds it to be 0 and therefore sits in a loop continually testing
'turn' to see when it becomes 1.
• Continuously testing a variable waiting for some value to appear is called the busy
waiting.
• When process 1 exit from critical region it set turn to 1 and now process 2 can find it
to be 1 and enters in to critical region.
• In this way both the process get alternate turn to enter in critical region.
• Taking turns is not a good idea when one of the processes is much slower than the
other.
• Consider the following situation for two processes P0 and P1


3

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller vaibhav51ppsv2020. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $5.19. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79271 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$5.19
  • (0)
  Add to cart