ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU-(2020-2021)-1 > online discussion >
online discussion-5 Version 0
👤 Author: by writer 2020-10-27 02:11:19
discuss what is critical-section problem and how to solve the problem

Please login to reply. Login

kagenzaclaudiengmailcom • 2020-10-27 14:14:08
<h2>Critical Section Problem</h2>
A Critical Section is a code segment that accesses shared variables and has to be executed as an atomic action. It means that in a group of cooperating processes, at a given point of time, only one process must be executing its critical section. If any other process also wants to execute its critical section, it must wait until the first one finishes.
<p class="center"><img src="https://www.studytonight.com/operating-system/images/critical-section-problem.png" alt="Critical Section Problem" data-cfsrc="images/critical-section-problem.png" /></p>


<hr />

<h3>Solution to Critical Section Problem</h3>
A solution to the critical section problem must satisfy the following three conditions:

<hr />

<h4>1. Mutual Exclusion</h4>
Out of a group of cooperating processes, only one process can be in its critical section at a given point of time.

&nbsp;
<h4>2. Progress</h4>
If no process is in its critical section, and if one or more threads want to execute their critical section then any one of these threads must be allowed to get into its critical section.

&nbsp; PostVer 0

Please login to reply. Login

wx287_oz26ft1wt2_isbggtha4lgepaasa • 2020-10-27 14:40:55
PostVer 0

Please login to reply. Login

962305148qqcom • 2020-10-27 14:41:46
Imagine a situation in which N processes compete to access Shared data

Each process has a piece of code, called a critical section, through which it accesses Shared data

Other code does not access the Shared data

At least one of the n pro

cesses even modified the Shared dataHow do you ensure that when a process I is executing in its own critical section, no other process J is executing in its critical section?

&nbsp;

Solution

Mutual exclusion conditions (only a finite number of processes in a critical section)

Give way to leisure:

if

No process is in its critical zone, and some processes request access to its critical zone

then

Only those that are not in the process of remainder sections can participate in the election from entering the critical section, and the election does not allow indefinitely postponing (limited entry into the critical section)

Limited waiting

There is an upper bound on the number of times a process enters its critical section between the time it requests it and the time it is allowed to enter

Assume that each process is executing continuously

Do not consider the relative execution speed between N processes

&nbsp;

&nbsp;

Define two processes to share data

int turn;

And take the initial value turn=0;

turn=i; The process Pi can enter the critical section

Process Pi

do{

while(trun! =i)

Critical section // Wait

turn=j;

Remainder. Section / / return

}while(1); PostVer 0

Please login to reply. Login

997371991qqcom • 2020-10-27 14:45:15
张时敏2018329621069

critical section:Consider a system consisting of n processes {P0, P1, ..., Pn −1}. Each process has a segment of code, called a critical section, in which the process may be accessing — and updating — data that is shared with at least one other process. 1. Mutual exclusion.IfprocessPi is executing in its critical section, then no other processes can be executing in their critical sections. 2. Progress. If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot bepostponed indeinitely. 3. Bounded waiting. There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted PostVer 0

Please login to reply. Login

512858048qqcom • 2020-10-27 14:45:40
The <strong>critical section problem</strong> refers to the problem of how to ensure that at most one process is executing its critical section at a given time. The critical section is a code segment where the shared variables can be accessed. An atomic action is required in a critical section.Only one process can execute in its critical section at a time. All the other processes have to wait to execute in their critical sections.

<strong>Solutions:</strong>
<ol>
<li><strong>Peterson’s Solution</strong> is a classical software based solution to the critical section problem.In Peterson’s solution, we have two shared variables:1. boolean flag[i] :Initialized to FALSE, initially no one is interested in entering the critical section 2.int turn : The process whose turn is to enter the critical section.</li>
<li><strong>TestAndSet</strong> is a hardware solution to the synchronization problem. In TestAndSet, we have a shared lock variable which can take either of the two values, 0 or 1.Before entering into the critical section, a process inquires about the lock. If it is locked, it keeps on waiting until it becomes free and if it is not locked, it takes the lock and executes the critical section.</li>
</ol>
The critical section problem needs a solution to synchronize the different processes. The solution to the critical section problem must satisfy the following conditions −

Mutual Exclusion
Mutual exclusion implies that only one process can be inside the critical section at any time. If any other processes require the critical section, they must wait until it is free.

Progress
Progress means that if a process is not using the critical section, then it should not stop any other process from accessing it. In other words, any process can enter a critical section if it is free.

Bounded Waiting
Bounded waiting means that each process must have a limited waiting time. Itt should not wait endlessly to access the critical section. PostVer 0

Please login to reply. Login

1285795916qqcom • 2020-10-27 14:51:07
邱锐鹏 2018329621199

My answer is in the picture:

<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/10/Screenshot_20201027_144713.jpg"><img class="alignnone size-medium wp-image-8719" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/10/Screenshot_20201027_144713-110x300.jpg" alt="" width="110" height="300" /></a> PostVer 0

Please login to reply. Login

244766935qqcom • 2020-10-27 14:57:09
PostVer 0

Please login to reply. Login

1720650158qqcom • 2020-10-27 14:57:34
<strong>critical-section</strong>:A critical section is a sequence of code that atomically accesses shared state.

Solution to Critical-Section Problem:

1.<strong> Mutual Exclusion</strong> - If process Pi is executing in its critical section, then no other processes can be executing in their critical sections

2. <strong>Progress</strong> - If no process is executing in its critical section and there exist some processes that wish to enter their critical section, then the selection of the processes that will enter the critical section next cannot be postponed indefinitely

3. <strong>Bounded Waiting</strong> - A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted Assume that each process executes at a nonzero speed No assumption concerning relative speed of the N processes PostVer 0

Please login to reply. Login

1403861656qqcom • 2020-10-27 14:57:36
Critical section definition: A block of code consisting of multiple statements caused by running multiple threads simultaneously within a function. When multiple threads operate on the same block of memory space, the critical section problem can occur. For multiple threads to access the critical section, thread synchronization can be used to solve the problem. There are two ways to achieve thread synchronization: mutex and semaphore. PostVer 0

Please login to reply. Login

yeqirunoutlookcom • 2020-10-27 14:57:50
Critical section
It means that multiple processes can change common variables, update the same table, and access the code section of the same file. When one of the processes enters the critical section, no other process can enter the critical section.

Critical section problem
It is to design an agreement that allows processes to collaborate. Each process must enter the critical zone through a request. The code that implements this request is called the entry zone. After the critical zone, there will be an exit zone. Other codes are called the remaining zone.
Mutually exclusive
Going forward, if there is no process in the critical area, and there are processes that need to enter the critical area, then only those processes that are not executing in the remaining area can participate in the selection, and this selection cannot be postponed indefinitely.
Limited waiting. From a process making a request to enter the critical section, until the request allows, the number of times other programs are allowed to enter its critical section has an upper limit.
Assume that the execution speed of each process is not 0
Cannot make any assumptions about the relative speed of n processes PostVer 0

Please login to reply. Login

1756894282qqcom • 2020-10-27 14:58:18
PostVer 0

Please login to reply. Login

1756894282qqcom • 2020-10-27 14:58:33
PostVer 0

Please login to reply. Login

244766935qqcom • 2020-10-27 15:00:50
<strong>A critical section :</strong> a critical section is a sequence of code that atomically accesses shared state.

&nbsp;

Solutions - Three Requirements:

&nbsp;

<strong>1.Mutual exclusion</strong>. If process Piis executing in its critical section, then no other processes can be executing in their critical sections.

<strong>2.Progress</strong>. If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in decidingwhichwillenteritscriticalsectionnext,andthisselectioncannot be postponed indefinitely.

<strong>3.Bounded waiting</strong>. There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.

&nbsp; PostVer 0

Please login to reply. Login

804824950qqcom • 2020-10-27 15:02:04
Critical section definition: A code block composed of multiple statements caused by multiple threads running simultaneously in a function.
When multiple threads operate on the same memory space, critical section problems may occur.

Solution:For multiple threads to access the critical section, you can use thread synchronization to solve. PostVer 0

Please login to reply. Login

1079513613qqcom • 2020-10-27 15:19:04
<blockquote>A critical section is a sequence of code that atomically accesses shared state.

Mutal exclusion
At most one thread holds the lock.
Progress
If no thread holds the lock and any thread attempts to acquire the lock, then eventually some thread succeeds in acquiring the lock.
Bounded waiting
If thread T attempts to acquire a lock, then there exists a bound on the number of times other threads can successfully acquire the lock before T does.</blockquote>
&nbsp; PostVer 0

Please login to reply. Login

1224532347qqcom • 2020-10-27 15:26:33
A critical section is a mechanism that prevents multiple threads from executing a particular section of code simultaneously. Therefore, it is necessary for sleep () to artificially make the time slice of the incoming thread come out after the atomic operation, which is similar to Mutex, and the only difference is that there is a deadlock problem when using the two functions, not the operating system control, the time slice is not well controlled. PostVer 0

Please login to reply. Login

2031115154qqcom • 2020-10-27 15:57:45
<p class="p1"><span class="s1">critical section is a program segment that access the shared resource.suppose that there are two program and they would access the shared resource</span><span class="s2">,</span><span class="s1">so each of them has its own critical section</span><span class="s2">,</span><span class="s1">furthermore</span><span class="s2">,</span><span class="s1">if one process is running its own critical section</span><span class="s2">,</span><span class="s1">the other can</span><span class="s2">’</span><span class="s1">t run its own critical section. </span></p>
<p class="p1"><span class="s1">As for the solution of critical-section problem</span><span class="s2">,</span><span class="s1">it must satisfy three demands. firstly</span><span class="s2">,</span><span class="s1">it must be ensured that the shared resource or critical-section-resource is accessed by only one progress</span><span class="s2">,</span><span class="s1">and other progress must wait until the shared resource is released</span><span class="s2">,</span><span class="s1">which calls mutual exclusion. And at the same time</span><span class="s2">,</span><span class="s1">the waiting time should be limited</span><span class="s2">,</span><span class="s1">which calls bounded waiting. secondly</span><span class="s2">,</span><span class="s1">if the critical-section-resource leave unused and one progress apply to use resource</span><span class="s2">,</span><span class="s1">this progress should have access to the shared resource. There are two ways to solve the critical-section problem</span><span class="s2">,</span><span class="s1">one is the soft-ware way and the other is the hard-ware way.Both of them have enter-section and leave-section.Before the process run its critical section</span><span class="s2">,</span><span class="s1">it must request and only the request is permitted can the process run its critical section. After the process run its critical section</span><span class="s2">,</span><span class="s1">there has a leaving section for switching to other process to access the shared resource. In the soft-ware way</span><span class="s2">,</span><span class="s1">there has a flag array restore the Boolean value of each process</span><span class="s2">,</span><span class="s1">true value stand for this process is using the critical-section resource</span><span class="s2">,</span><span class="s1">and false value stand for the opposite condition. In the hard-ware way</span><span class="s2">,</span><span class="s1">before one process access the shared resource</span><span class="s2">,</span><span class="s1">it would use check and set function:</span></p>
<p class="p1"><span class="s1">key = true</span><span class="s2">;</span></p>
<p class="p1"><span class="s1">while</span><span class="s2">(</span><span class="s1">key&amp;&amp;lock</span><span class="s2">)</span></p>
<p class="p1"><span class="s1"><span class="Apple-converted-space">      </span>swap</span><span class="s2">(</span><span class="s1">key</span><span class="s2">,</span><span class="s1">lock</span><span class="s2">);</span></p>
<p class="p1"><span class="s1">/*critical section*/</span></p>
<p class="p1"><span class="s1">lock=false</span><span class="s2">;</span></p> PostVer 0

Please login to reply. Login

2470994471qqcom • 2020-10-27 21:56:22
2018329621137_张翔
1.critical section:
Consider a system consisting of n processes {P0, P1, ..., Pn−1}. Each process has a segment of code, called a critical section, in which the process may be accessing — and updating — data that is shared with at least one other process. The important feature of the system is that, when one process is executing in its critical section, no other process is allowed to execute in its critical section. That is, no two processes are executing in their critical sections at the same time.
2.The critical-section problem is to design a protocol that the processes can use to synchronize their activity so as to cooperatively share data.
3.
A solution to the critical-section problem must satisfy the following three requirements:
a) Mutual exclusion. If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.
b) Progress. If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot be postponed indefinitely.
c)Bounded waiting. There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted. PostVer 0

Please login to reply. Login

653968106qqcom • 2020-10-28 13:24:06
2018329621008徐天然

critical section:A code block consisting of multiple statements caused by running multiple threads in a function at the same time.
When multiple threads operate on the same memory space, the critical-section problem may occur.
Suppose there are n processes (P1, P2, ...Pn)Each of them has a critical section that can modify the shared variables (variables, files, database tables, etc.). When any process is required to execute in the critical section, the others cannot be executed.


how to solve
The solution of critical area problem should meet the following three requirements:
Mutual exclusion: When a thread is executing in its critical section, no other threads can be executing in their critical sections.
Progress: If no thread is executing in its critical section, and if there are some threads that wish to enter their critical sections, then one of these threads will get into the critical section.
Bounded waiting: After a thread makes a request to enter its critical section, there is a bound on the number of times that other threads are allowed to enter their critical sections, before the request is granted.
There are two common methods to deal with the critical region problem of operating system: preemptive kernel and non preemptive kernel.
Preemptive kernel allows processes in kernel mode to be preempted;
Non preemptive kernel does not allow processes in kernel mode to be preempted. A process running in kernel mode runs until it exits kernel mode, blocks, or voluntarily relinquishes CPU control. PostVer 0

Please login to reply. Login

1730854984qqcom • 2020-10-30 08:24:26
The critical-section problem is to design a protocol that the processes can use to synchronize their activity so as to cooperatively share data.
A solution to the critical-section problem must satisfy the following three requirements:
1. Mutual exclusion. If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.
2. Progress. If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot be
postponed indefinitely.
3. Bounded waiting. There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
PostVer 0

Please login to reply. Login

cfeshete97gmailcom • 2020-10-30 15:12:55
Name: FESHETE CHARLES DE-GAULLE

2018529627022

critical section:A code block consisting of multiple statements caused by running multiple threads in a function at the same time. When multiple threads operate on the same memory space, the critical-section problem may occur. Suppose there are n processes (P1, P2, ...Pn)Each of them has a critical section that can modify the shared variables (variables, files, database tables, etc.). When any process is required to execute in the critical section, the others cannot be executed. how to solve The solution of critical area problem should meet the following three requirements: Mutual exclusion: When a thread is executing in its critical section, no other threads can be executing in their critical sections.

<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2020/10/Critical-Section-Problem.png"><img class="alignnone size-full wp-image-8722" src="http://www.yvsou.com/wp-content/uploads/sites/30/2020/10/Critical-Section-Problem.png" alt="" width="228" height="221" /></a> PostVer 0

Please login to reply. Login

hokyeejaufoxmailcom • 2020-11-01 13:34:47
Informally, a <strong>critical section</strong> is a code segment that accesses shared variables and has to be executed as an atomic action. The <strong>critical section</strong> problem refers to the problem of how to ensure that at most one process is executing its critical section at a given time.

Important: Critical sections in different threads are not necessarily the same code segment.

<strong>The critical-section problem </strong>is to design a protocol that the processes can use to cooperate. Each process must request permission to enter its critical section. The section of code implementing this request ist the entry section.

A solution to the critical section problem must satisfy the following three requirements:
<ol>
<li>Mutual exclusion. If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.</li>
<li>Progress. If no process is executing in its critical section and som processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in the decision on which will enter its critical section next, and this selection cannot be postponed indefinitely.</li>
<li>Bounded waiting. There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.</li>
</ol> PostVer 0

Please login to reply. Login

454234624qqcom • 2020-11-02 20:19:40
Consider a system consisting of n processes {P<sub>0</sub>, P<sub>1</sub>, ……, P<sub>n-1</sub>}. Each process has a segment of code, called a<strong> critical section</strong>, in which the process may be changing common variables, updating a table, writing a file, and so on. The important feature of the system is that, when one process is executing in its critical section. That is, no two processes are executing in their critical sections at the same time.

The<strong> critical-section problem</strong> is to design a protocol that the processes can use to cooperate. Each process must request permission to enter its critical section. The section of code implementing this request is the entry section. The critical section may be followed by an exit section. The remaining code is the remainder section.

A solution to the critical-section problem must satisfy the following three requirements:
<ol>
<li><strong>Mutual exclusion.</strong> If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.</li>
<li><strong>Progress. </strong>If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in the decision on which will enter its critical section next, and this selection cannot be postponed indefinitely.</li>
<li><strong>Bounded waiting.</strong> There exists a bound, or limit, on the number of times</li>
</ol>
that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.

Two general approaches are used to handle critical sections in operating systems: (1) <strong>preemptive kernels</strong> and (2) <strong>nonpreemptive kernels.</strong>

&nbsp; PostVer 0

Please login to reply. Login

1210775967qqcom • 2020-11-02 22:38:20
The critical-section problem is <strong>to design a protocol that the processes can use to cooperate.</strong> Each process must request permission to enter its critical section, of which the solutions should satisfies:
1. <strong>Mutual exclusion</strong>: If process P is executing in its critical section, then no other processes can be executing in their critical sections.
2. <strong>Progress</strong>: If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in the decision on which will enter its critical section next, and this selection cannot be postponed indefinitely.
3. <strong>Bounded waiting</strong>: There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
Two general approaches are used to handle critical sections in operating systems: (1) <strong>preemptive kernels</strong> and (2) <strong>nonpreemptive kernels</strong>. A preemptive kernel allows a process to be preempted while it is running in kernel mode. A nonpreemptive kernel does not allow a process running in kernel mode to be preempted; a kernel-mode process will run until it exits kernel mode, blocks, or voluntarily yields control of the CPU. A nonpreemptive kernels must be carefully designed to ensure that shared kernel data are free from race conditions. PostVer 0

Please login to reply. Login

1119833189qqcom • 2020-11-10 18:46:01
The part of each process that accesses critical resources is called a critical section (a critical resource is a Shared resource that is allowed to be used by only one process at a time). Only one process is allowed to enter the critical section at a time, and no other process is allowed to enter after entering.
Scheduling principles for processes entering critical sections
(1) If several processes require access to an idle critical section, allow only one process at a time. No more than one process may be in the critical zone at any time. If an existing process enters its own critical section, all other processes attempting to enter the critical section must wait. (3) the process into the critical area to exit in a limited time, so that other processes can enter their critical area in time. (4) if the process can not enter their critical section, should give up the CPU, to avoid the process appears "busy" phenomenon.
Mutex is one of the simplest kernel objects, which can easily achieve exclusive access to a resource. Because it is a kernel object, it can generate signals, which, in fact, is used in programs to achieve mutual exclusion.
A critical section is not a kernel object, but a system-provided data structure that a program can declare a variable of that type and then use to achieve exclusive access to resources. When you want to access a critical resource, first lock the critical section (if the critical section is not free, wait), after using up the resource, the critical section will be released.
They are generally used for synchronization between threads, and are often used interchangeably.
If you want to implement complex mutex, you should use other methods, such as semaphore kernel objects. The object of the critical section cannot span the process, but is the synchronization object of the Shared data area between threads. Mutexes can act as synchronization objects for Shared data areas between processes. PostVer 0

Please login to reply. Login

chipusilesgmailcom • 2020-11-17 14:29:34
The critical section is a code segment where the shared variables can be accessed. An atomic action is required in a critical section i.e. only one process can execute in its critical section at a time. All the other processes have to wait to execute in their critical sections.

&nbsp;

In the above diagram, the entry section handles the entry into the critical section. It acquires the resources needed for execution by the process. The exit section handles the exit from the critical section. It releases the resources and also informs the other processes that the critical section is free.

<strong>Solution to the Critical Section Problem</strong>

The critical section problem needs a solution to synchronize the different processes. The solution to the critical section problem must satisfy the following conditions −
<ul>
<li><strong>Mutual Exclusion</strong></li>
</ul>
Mutual exclusion implies that only one process can be inside the critical section at any time. If any other processes require the critical section, they must wait until it is free.
<ul>
<li><strong>Progress</strong></li>
</ul>
Progress means that if a process is not using the critical section, then it should not stop any other process from accessing it. In other words, any process can enter a critical section if it is free.
<ul>
<li><strong>Bounded Waiting</strong></li>
</ul>
Bounded waiting means that each process must have a limited waiting time. Itt should not wait endlessly to access the critical section.

&nbsp; PostVer 0

Please login to reply. Login

1079513613qqcom • 2020-12-10 12:14:47
Imagine a situation in which N processes compete to access Shared data Each process has a piece of code, called a critical section, through which it accesses Shared data Other code does not access the Shared data At least one of the n pro cesses even modified the Shared dataHow do you ensure that when a process I is executing in its own critical section, no other process J is executing in its critical section?   Solution Mutual exclusion conditions (only a finite number of processes in a critical section) Give way to leisure: if No process is in its critical zone, and some processes request access to its critical zone then Only those that are not in the process of remainder sections can participate in the election from entering the critical section, and the election does not allow indefinitely postponing (limited entry into the critical section) Limited waiting There is an upper bound on the number of times a process enters its critical section between the time it requests it and the time it is allowed to enter Assume that each process is executing continuously Do not consider the relative execution speed between N processes     Define two processes to share data int turn; And take the initial value turn=0; turn=i; The process Pi can enter the critical section Process Pi do{ while(trun! =i) Critical section // Wait turn=j; Remainder. Section / / return }while(1); PostVer 0

Please login to reply. Login

450766287qqcom • 2020-12-22 13:34:30
A critical section is a segment of code which can be accessed by a signal process at a specific point of time. The section consists of shared data resources that required to be accessed by other processes.
The entry to the critical section is handled by the wait() function, and it is represented as P().
The exit from a critical section is controlled by the signal() function, represented as V().
In the critical section, only a single process can be executed. Other processes, waiting to execute their critical section, need to wait until the current process completes its execution.


Solution:
Peterson Solution: when a process is executing in a critical state, then the other process only executes the rest of the code, and the opposite can happen. This method also helps to make sure that only a single process runs in the critical section at a specific time.

Synchronization Hardware: Some times the problems of the Critical Section are also resolved by hardware. Some operating system offers a lock functionality where a Process acquires a lock when entering the Critical section and releases the lock after leaving it. So when another process is trying to enter the critical section, it will not be able to enter as it is locked. It can only do so if it is free by acquiring the lock itself.

Mutex Locks: Synchronization hardware not simple method to implement for everyone, so strict software method known as Mutex Locks was also introduced. In this approach, in the entry section of code, a LOCK is obtained over the critical resources used inside the critical section. In the exit section that lock is released.

Semaphore Solution: Semaphore is simply a variable that is non-negative and shared between threads. It is another algorithm or solution to the critical section problem. It is a signaling mechanism and a thread that is waiting on a semaphore, which can be signaled by another thread. It uses two atomic operations, 1)wait, and 2) signal for the process synchronization.

PostVer 0

Please login to reply. Login

shatino94163com • 2020-12-22 14:35:31
Critical section It means that multiple processes can change common variables, update the same table, and access the code section of the same file. When one of the processes enters the critical section, no other process can enter the critical section. Critical section problem It is to design an agreement that allows processes to collaborate. Each process must enter the critical zone through a request. The code that implements this request is called the entry zone. After the critical zone, there will be an exit zone. Other codes are called the remaining zone. Mutually exclusive Going forward, if there is no process in the critical area, and there are processes that need to enter the critical area, then only those processes that are not executing in the remaining area can participate in the selection, and this selection cannot be postponed indefinitely. Limited waiting. From a process making a request to enter the critical section, until the request allows, the number of times other programs are allowed to enter its critical section has an upper limit. Assume that the execution speed of each process is not 0 Cannot make any assumptions about the relative speed of n processes PostVer 0

Please login to reply. Login

439731491qqcom • 2021-01-05 15:52:02
<a href="http://www.yvsou.com/wp-content/uploads/sites/30/2021/01/捕获.png"><img class="alignnone size-medium wp-image-9291" src="http://www.yvsou.com/wp-content/uploads/sites/30/2021/01/捕获-300x161.png" alt="" width="300" height="161" /></a> PostVer 0

Please login to reply. Login

2736689890qqcom • 2021-01-06 20:40:56
2018329621239-严宇豪

The critical section is a code segment where the shared variables can be accessed. An atomic action is required in a critical section i.e. only one process can execute in its critical section at a time. All the other processes have to wait to execute in their critical sections.
The critical section problem needs a solution to synchronize the different processes. The solution to the critical section problem must satisfy the following conditions −

Mutual Exclusion
Mutual exclusion implies that only one process can be inside the critical section at any time. If any other processes require the critical section, they must wait until it is free.

Progress
Progress means that if a process is not using the critical section, then it should not stop any other process from accessing it. In other words, any process can enter a critical section if it is free.

Bounded Waiting
Bounded waiting means that each process must have a limited waiting time. Itt should not wait endlessly to access the critical section. PostVer 0

Please login to reply. Login

Reversion History

Loading...
No reversions found.