logo

Study on Operating System and Concurrency

15 Pages2543 Words38 Views
   

Added on  2020-04-13

Study on Operating System and Concurrency

   Added on 2020-04-13

ShareRelated Documents
Running head: OPERATING SYSTEM AND CONCURRENCY
Operating System and Concurrency
Name of the student:
Name of the University:
Author note:
Study on Operating System and Concurrency_1
OPERATING SYSTEM AND CONCURRENCY
Table of Contents
2.5 Program Report..........................................................................................................................3
1. The Tunnel Program................................................................................................................3
A..............................................................................................................................................3
B...............................................................................................................................................3
C...............................................................................................................................................3
D..............................................................................................................................................4
3. OS Theory and Concepts.............................................................................................................5
2. OS Abstraction and Process Management...............................................................................5
A..............................................................................................................................................5
B...............................................................................................................................................5
3. Security....................................................................................................................................7
A..............................................................................................................................................7
B...............................................................................................................................................7
C...............................................................................................................................................8
Appendix 1.....................................................................................................................................10
Study on Operating System and Concurrency_2
OPERATING SYSTEM AND CONCURRENCY
2.5 Program Report
1. The Tunnel Program
A.
A monitor is a high-level process of abstraction, which gives an effective and convenient
mechanism for process synchronization. It encourages that at a time, only a single process can
remain active in the monitor. This is known as mutual exclusion. This program uses monitor to
ensure that no two cars travel in opposite direction in the tunnel at the same time.
B.
Mutex is used in this process. It creates a monitor (Hung, Chauhan and Garg 2016). The
monitor, with the help of pthread library functions like lock(), cond_wait(), cond_signal() and
unlock() ensures that no two cars travel in opposite direction in the tunnel at the same time.
Whenever an approaching car encounters a car already inside the tunnel travelling in the opposite
direction, it calls the wait() and the thread goes to halt until the signal() is passed on condition
that opposite direction’s thread count is zero. Assertion is also made to ensure the condition is
satisfied throughout the program.
C.
Whenever the thread count on the same direction is found to be 3, the cond_wait() is
called by locking on to the mutex. This thread is only allowed to proceed when one of the
threads is released in the tunnel_exit(). The assertion made is ‘assert(n_in_tunnel[dir] <= 3);’.
Study on Operating System and Concurrency_3
OPERATING SYSTEM AND CONCURRENCY
This ensures that there will never be more than 3 cars in the same direction inside the tunnel, or
otherwise the program will exit with an error message.
D.
A deadlock is a situation where one or more processes keep waiting for shared resources
whereas they are being continually accessed by other processes. Here, it is made sure that no
more than 6 cars can travel in a direction through the tunnel, if the waitingFlag is made true. This
takes away resources from the process of a particular direction by making it to wait on condition.
Further it grants access to the opposite process and locks on to the tunnel mutex. Assertions is
also made to ensure the condition is satisfied throughout the program.
Study on Operating System and Concurrency_4

End of preview

Want to access all the pages? Upload your documents or become a member.