The document discusses the critical section problem in operating systems and algorithms to solve it. The critical section problem occurs when multiple processes need exclusive access to a shared resource. Three key properties must be satisfied by any solution: mutual exclusion, progress, and bounded waiting. The document presents and analyzes several algorithms to solve the problem for two processes, including using flags and turn-taking variables. It also introduces semaphores as a synchronization primitive and discusses their implementation and usage to solve the critical section problem.
Semaphore = a synchronization primitive
higher level of abstraction than locks
invented by Dijkstra in 1968, as part of the THE operating system
A semaphore is:
a variable that is manipulated through two operations, P and V (Dutch for “test” and “increment”)
P(sem) (wait/down)
block until sem > 0, then subtract 1 from sem and proceed
V(sem) (signal/up)
add 1 to sem
Do these operations atomically
Semaphore = a synchronization primitive
higher level of abstraction than locks
invented by Dijkstra in 1968, as part of the THE operating system
A semaphore is:
a variable that is manipulated through two operations, P and V (Dutch for “test” and “increment”)
P(sem) (wait/down)
block until sem > 0, then subtract 1 from sem and proceed
V(sem) (signal/up)
add 1 to sem
Do these operations atomically
In these slides I discussed about deadlock,causes of deadlock,effects of deadlock,conditions of deadlock,resource allocation graph,deadlock handling strategies,deadlock prevention,deadlock avoidance,deadlock avoidance and resolution....I haven't touch algorithms section in these slides.....and last thing I want to say that don't forget to follow me...
The objectives of Deadlocks in Operating Systems are:
- To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks
- To present a number of different methods for preventing or avoiding deadlocks in a computer system
This slide tells about the Digital Portfolio and footprint creation in the internet through social media. Its a must for college students to showcase their skills and accomplishments.
This slide shows the question paper setting for Computer science and engineering. How to set a question using Higher Order Thinking Skills. This slide will be an eye opener for those who need to set an higher order thinking question
When you add a new module or modify a existing source code, then ns2 needs to be recompiled. How to recompile and where to do the modifications are mentioned in this slide
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
2. CS Problem
● When one process is executing in its critical
section, then no process is allowed to execute in its
critical section, thus the execution of CS by the
processes is mutually exclusive in time
4. CS problem
● A solution to CS problem must satisfy
● Mutual exclusion: if process Pi is executing in its CS, then
no other processes can be executing in their CS
● Progress: if no process is executing in its CS and some
processes want to enter thier CS, then only those processes
that are not executing in their remainder section can
participate in the decision on which will enter its CS next,
and this selection cannot be postponed indefinitely
● Bounded Waiting: There exists a bound on the number of
times that other processes are allowed to enter their CS after
a process has made a request to enter its CS and before that
is granted
5. Two process solution for CS
● Assume there are only two processes P0 and P1 at
a time.
● For convenience, when presenting Pi, we use Pj to
denote the other process, that is j=1-i
6. Algorithm 1
Do{
While (turn != i);
Critical section
Turn =j;
Remainder section
}while(1);
if turn==i, then process Pi is allowed to execute CS
● Mutual exclusion is satisfied, but the progress is not
satisfied
● If turn==0 and P1 is ready to enter CS, P1 cannot do,
eventhough P0 may be in its remainder section
8. Algorithm 2
● Boolean flag[2];
● If flag[i] is true, then P1 is allowed to enter its CS.
● Mutual exclusion is satisfied and progress is not
satisfied
● P0 sets flag[0]=true;
● P1 sets flag[1]=true;
● Both P0 and P1 are looping forever in their
respective while statements.
9. Algorithm 3
● The processes share two variables
● Boolean flag[2]
● Int turn;
● Initial values of flag[0] and flag[1] is false and turn
value either 0 or 1 (immaterial)
● All the three are satisfied
● Progress
● Mutual exclusion
● Bounded waiting
11. Algorithm 3
● Pi can enter its CS only when either flag[j]=false
and turn=i
● And if P0 and P1 change the flag[0] and flag[1]
simultaneously to true and wanted to execute its
CS, then turn =0 or 1 can happen only one at a
time, so progress is satisfied.
12. Semaphores
● Two atomic operations
● P – wait – proberen (Dutch)
● V – signal – verhogen
● Pseudocode is
● wait(S)
While (S<=0)
;//no operation
S--;
● }
13. Semaphores
Signal (S)
{
S++;
}
● Modification to the integer value of the semaphore in
the wait and singal operations.
● That is when one process changes the semaphore value,
no other process can simultaneously modify that same
semaphore value.
14. Semaphore implementation
typedef struct {
Int value;
Struct process *L;
}semaphore;
each semaphore has an integer value and list of
processes. When a process must wait on a
semaphore, it is added to the list of processes.
● A signal operation removes one process from the
list of waiting processes and awakens that process
17. Deadlock Situations
• Mutual exclusion. At least one resource must be held in a
non sharable mode; that is, only one process at a time can
use the resource. If another process requests that
resource, the requesting process must be delayed until the
resource has been released.
• Hold and wait. A process must be holding at least one
resource and waiting to acquire additional resources that
are currently being held by other processes.
18. Deadlock
• No preemption. Resources cannot be preempted; that is,
a resource can be released only voluntarily by the process
holding it, after that process has completed its task.
• Circular wait. A set { P0 , Pl, ... , P11 } of waiting processes
must exist such that Po is waiting for a resource held by
P1, P1 is waiting for a resource held by P2, ... , Pn-1 is
waiting for a resource held by P,v and P11 is waiting for a
resource held by Po.
19. Resource Allocation Graph
• The sets P, K and E:
• P == {P1, P2, P3}
• R== {R1, R2, R3, ~}
• E == {Pl -> Rl P2-> R3, Rl->P2, R2->P2, R2-> Pl, R3-> P3}
• Resource instances:
• One instance of resource type R1
• Two instances of resource type R2
21. Resource Allocation Graph
• One instance of resource type R3
• Three instances of Resource R4
• Process states:
• Process P1 is holding an instance of resource type R2 and is
waiting for an instance of resource type R1 .
• Process P2 is holding an instance of R1 and an instance of R2 and
is waiting for an instance of R3.
• Process P3 is holding an instance of R3nces of resource type R4
22. Resource Allocation Graph
• One instance of resource type R3
• Three instances of Resource R4
• Process states:
• Process P1 is holding an instance of resource type R2 and is
waiting for an instance of resource type R1 .
• Process P2 is holding an instance of R1 and an instance of R2 and
is waiting for an instance of R3.
• Process P3 is holding an instance of R3nces of resource type R4
25. Handling Deadlocks
• We can use a protocol to prevent or avoid deadlocks,
ensuring that the system will never enter a deadlocked
state.
• We can allow the system to enter a deadlocked state,
detect it, and recover.
• We can ignore the problem altogether and pretend that
deadlocks never occur in the system. (used in windows
and Unix OS)
26. Deadlock prevention
• Mutual Exclusion
• Handles non-sharable resource
• Read only files are the good examples, so any process can use
that resource, since it is sharable
• But printers are non sharable, they cannot be denied since printers
are intrinsically non sharable
27. Deadlock prevention
• Hold and Wait
• Whenever a process request any resource, it should not hold any
other resource
• Before a process begins its execution, all resource allocated to it.
• But when the process needs any new resource during its
execution, it should release the other resources.
• Starvation is possible in this case, as some process will wait
indefinitely to use a resource.
• Also resource utilization is low, that is the resources are unused for
a long period.
• Example: if a process wanted to copy some files from a DVD to
disk and then sort the files and printing it. A Process may request
DVD and disk, once the copying is done, it may request the Printer
rather than locking everything in the beginning.
28. Deadlock prevention
• No Preemption
• If a process requests some resources, we first check whether they
are available and we allocate them.
• If they are not, we check whether they are allocated to some other
process that is waiting for additional resources. If so, we preempt
the desired resources from the waiting process and allocate them
to the requesting process. If the resources are neither available nor
held by a waiting process, the requesting process must wait. While
it is waiting, some of its resources may be preempted, but only if
another process requests them.
• This protocol is often applied to resources whose state can be
easily saved and restored later, such as CPU registers and memory
space. It cannot generally be applied to such resources as printers
and tape drives.
29. Deadlock prevention
• Circular Wait
• To avoid deadlock with this, a number can be allotted to each
resource
• Any process can request the resource in terms of increasing order
• For example F(tape)=1, F(disk)=5, F(printer) =12, a process which
need tape and printer can request only tape first and then the
printer. Till that time some other process can use the printer
• While releasing the resource also, the processes will release in the
descending order of Numbers.
32. Deadlock Avoidance
• Requires knowledge of future process resource request
• Two approaches
• do not start a process if its demands might lead to deadlock
• Do not grant any incremental resource request to a process if this
allocation might lead to deadlock
33. Deadlock Avoidance
Resource R = (R1,R2,……Rn) Total amount of each resource in
the system
Available V = (V1,V2,V3,…..Vn) Total amount of each resource not
allocated to any process
Claim C= Cij = requirement of process i for
c11 c12 ...... c1m resource j
c21 c22 ...... c2m
....
Cn1 cn2........cnm
Allocation A = Aij = current allocation to process i of
a11 a12 ...... a1m resource j
a21 a22 ...... a2m
....
an1 an2........anm
34. Banker’s algorithm
• Safe State
• Is one in which there is at least one sequence of resource
allocations to processes that does not result in deadlock (All
process run to completion)
• Unsafe state
• A state that is not safe