In: Computer Science
Operating Systems Concepts
What difficulties arise from concurrency?
Concurrency means process or several instruction running at the same time . In OS a process is divided into multiple threads and some threads runs in parallel. they uses a shared memory or sharing same resource . There are many resources that are commonly shared among many threads .
Concurrency does not mean that more than one processes are running simultaneously in the CPU Just Remember that a single process can only be present at CPU at any point of time in a Uni-processor system.
Problems in Concurrency
1.Sharing some global resources is difficult as i=global resources are common to all so it mayn't be allocated to everyone at one point of time. So safety of resources is a problem.
2.Optimally allocating resources to more than one process
3.Programming errors can occur because a shared resource is being updated by many process so at the end it may lead to error .
What are the requirements necessary to support mutual exclusion?
Mutual Exclusion is a very important property to satisfy synchronization between different processes . It means that only one process can be present at any time inside critical section using shared resources . As critical section contains shared resources so by allowing only one process at a time we can make sure no redundancy or deadlock will occur
1 No Deadlock
2. No starvation every process will get a chance to execute .
3. Fairness every process will get equal and fair chance to execute its instructions .
4. Consider a reader -writer problem if any reader is reading then no writer is allowed to enter and update the data before reader exit the shared region and vice versa . As it may lead to a problem of synchronization between the two.
3. Does interrupt disabling work on multiprocessors? Why?
No Interrupt Disabling doesn't work on multiprocessors systems. It works on only uni-processor system .In this mechanism a process before entering into critical section disables the interrupt and enabling the interrupt after it enters into Critical section So mutual exclusion is achieved as no other process can interrupt the already running process in between it's execution thus it excludes all other processes from entering into CS.
So this technique is used and applicable for only Uni -processor CPU but now lets talk about multiprocessors
IN multiprocessors many processes run in different CPUs' at so let's say if any process of CPU 1 disable interrupt then only process in CPU 1 cannot enter into CS as their interrupt is enabled . But processes running in other CPU's like CPU 2 Or CPU 3 then those processes don't have any boundation on entering CS they can enter the CS and fight for the shared resource and access them at same point of time which may lead to deadlock or programming erros can occure
so disabling interrupt doesn't work on multiprocessors as it doesn't make sure of mutual exclusion in multiprocessors systems