Total operating device management understanding of concurrent processes virtual memory management

Device Management

P294 page 5, 7 questions.

5.

To sum up the number of scheduling the order 5,3,2,1,4 disk rotations happened

7.

(1) a first-come, first-served FCFS algorithm is 565, followed by 143-86-147-91-177-94-150-102-175-130.

(2) Find the shortest time first algorithm SSTF 162, followed by 143-147-150-130-102-94-91-86-175-177.

(3) scanning algorithm SCAN 169, followed by 143-147-150-175-177-199-130-102-94-91-86.

(4) The elevator dispatcher 125 (Xianxiang direction addresses large), followed 143-147-150-175-177-102-94-91-86. For the (direction Xianxiang address small) 148 were 143-130-102-94-91-86-147-150-175-177.

Understanding of concurrent processes

First, the sequence programming:

Sequential programming has four properties: deterministic reproducibility (1) sequential execution (2) closure (3) the results of the environment (4) process. Its execution speed regardless of the program sequence, i.e., the final output of the program related to the initial input data only, regardless of the time.

Order structure is the simplest program structure, is the most common program structure, as long as the corresponding statement in accordance with the written order to solve the problem on the line, it's execution order is from top to bottom, in sequence.

Second, concurrent programming:

It refers to concurrent programming method of programming a number of program modules may be composed of a program executed simultaneously. This module can be executed while the program is called process. Process the data and statements related sequences. A program composed of a plurality of processes can be simultaneously performed in parallel on multiple processors, may be performed on a plug clip processor. It enables concurrent programming using the peripheral devices and processors working in parallel, reduce execution time and improve the efficiency of the computer system.

example:

Concurrent Programming:

If the program has a large number of computing tasks, and the tasks can be split into several blocks mutually independent tasks, it should be used in parallel programming. Parallel Programming CPU utilization temporarily increased to improve throughput, if the CPU of the client system is often in an idle state, this method is very useful, but are generally not suitable for server system. Most server itself and parallel processing capability, for example, ASP.NET can handle multiple requests in parallel. In some cases, write parallel code on the server system is still useful (if you know the number of concurrent users will always be a minority). But typically performed on the server system for parallel programming, the parallel processing capabilities to reduce itself, and no real benefit.

Sequential programming:

a = 3, b = 5, the exchange current values ​​of a, b, and exchanged if this problem two cups of water, of course, to use a third cup, if the third cup is C, then the procedure is correct: c = a; a = b; b = c; execution result is a = 5, b = c = 3, if changing the order written as: a = b; c = a; b = c; then the execution result becomes a = b = c = 5, can not achieve the intended purpose, beginners most likely to commit such a mistake. Sequence structure can be used independently to form a complete simple procedure, the common input, calculates the output trilogy is the order of the program structure, for example, calculate the area of ​​a circle, which is the input order of the program statement radius of the circle r, calculates s = 3.14159 * r * r, the output area of ​​a circle s. However, most cases are sequential structure as part of the program, the other program structure composed of a complex with, for example, the compound statement branching structure, the cyclic structure like loop.

Mutual exclusion and synchronization

1. Concurrent with the parallel explained and described relationship between the two.

Concurrent essentially a physical CPU (may be a plurality of physical CPU) multiplexed between a plurality of channel programs for enforcing concurrency is shared by multiple users of the limited physical resources in order to improve efficiency.
Parallelism refers to two or more events or activities occur at the same time. In a multiprogramming environment parallelism same time a plurality of programs can be executed simultaneously on different CPU.

 Concurrent with two parallel are both similar concept without the same: concurrency, also known as total line resistance, is the ability to handle multiple simultaneous sexual activity; parallel is two concurrent events occurring refers to simultaneous, concurrent with meaning, but not necessarily concurrent parallel, it also does not have to mean the same moment between concurrent events.

2. What are the relationships between processes? Respectively, to take what strategy?

There are two basic inter-process relationships: competition and assistance.

Multiple interactive processes, they share a computer resource, so that the various processes that are not present due to the logic of sharing resources and constraints arising interactive relationship, which is an indirect constraint relationship, also known as mutually exclusive relationship.

A branch operation involving a set of concurrent processes that require division of labor in order to complete a common task, since each process independently to promote the unpredictable rate, on the order of execution will have constraints, the need for mutual cooperation in the process of coordinate their work on certain key points.

3. Why is mutually exclusive processes is also a sync?

Mutual exclusion refers to a resource allows only the use of a process that you use the time I do not use, I use the time you do not use, this is a coordinated, consistent on a "pace", thus that is a synchronous.

4. Explain the deadlock and "hunger", and describe their relationship.

Deadlock: refers to the phenomenon of two or more processes (or threads) in the implementation process, a result of competition for resources caused by waiting for each other, in the absence of external force, they will not be able to promote it. At this time, say the system is in deadlock state or system to produce a deadlock, which is always in the process of waiting for another process called the deadlock.
Four conditions of deadlock
1, mutually exclusive conditions: thread access to resources is exclusive, if a thread takes up a resource, then the other threads must wait state until resources are freed.
2, the request and maintaining conditions: T1 thread holding at least one resource R1 has been occupied, but a request for another resource R2 is proposed, but this time, the resource R2 is occupied by another thread T2, T1 so that the thread has to wait, but R1 to keep their own resources are not released.
3, not deprivation: Resource thread has acquired, before not used, can not be deprived of other threads can only be released by their own after you are finished.
4, loop wait condition: When deadlock occurs, there must be a "process - Resource endless chain", namely: {p0, p1, p2, ... pn}, P0 process (or thread) waiting for a resource occupied p1 , p1 p2 waiting for resources consumed, pn p0 waiting for resources consumed. (The most intuitive understanding, p0 p1 waiting for resources occupied while waiting for resources p0 and p1 occupied, so the two processes will wait for each other)

Hunger is the main reason: in a dynamic system, for each type of system resources, the operating system needs to determine a distribution strategy, when multiple processes simultaneously apply for certain types of resources, allocation of resources to process the order determined by the allocation policy. Sometimes resource allocation strategy may not be fair, that does not guarantee the existence of an upper bound on latency  . In this case, even if the system does not deadlock, some processes may also be a long wait. It said the process was starved to death when the waiting time to process and respond to propel a significant impact, said the process took place hungry, hungry to a certain extent when the process is completed the mandate given even if no longer practical significance. For example, when there are multiple processes need to print a file, if the system allocation policy priority document printer is the shortest, the print job will be due to the long file of the arrival of a steady stream of short documents to be postponed indefinitely, and even lead to eventual starvation starve.
Hunger is not a necessary condition for their produce, and very random. And hunger can be eliminated, and therefore the hunger occur when busy waiting is called livelock.

Similarities and differences deadlock and hunger

Similarities: Both are caused due to compete for resources.

difference:

  1. From the state of the process, the process deadlock are in a wait state, the busy wait (in operation or ready state) process is not in a wait state, but it may be starved to death;
  2. Deadlock process waits resources will never be released, starved to death waiting for the process to be released but will not be assigned to their own resources, showing no wait time upper bound (or busy waiting wait formula);
  3. A deadlock occurs waiting loop, and starvation is not the case. This also shows that resource allocation map can be detected by the presence or absence of deadlock, but it can not detect whether the process of starvation;
  4. A deadlock involving multiple processes, while hunger or starvation process may be only one.
  5. In the case of hunger, the system has at least one process can run normally, but not enforced starvation process opportunities. The deadlock might eventually cause the entire system deadlock and collapse.

5. What is called the critical region? How the conflict settlement process access to critical resources?

Access to critical resources of each process in that part of the program known as the critical zone, a time only allowed a process to enter the critical section, enter
After the other processes are not allowed to enter

Treated with practical problems semaphore operation and PV

P187-43

Cemaphore

empty = 1; Orange essence = 0; sugar = 0; = 0 water;

Process product(){

While(true){

P(empty);

Generating a random number S;

If (s == 0) V (fine orange);

If(s==1) V(水);

If(s==2) V(糖);

  }

}

Process P1(){      | Process P2(){      | Process P3(){

While(true){        While(true){        While(true){

P (fine orange); P (sugar); P (water);

Orange fine removed; sugar removed; removal of water;

V(empty);        V(empty);            V(empty);

    }             }             }

  }             }            }

 

Coend

2.IPO problem: There are multiple input processes, multiple processes and multiple output processing process. Stepwise process input data input to a buffer on the M units B1, after treatment by the process into the process there is the buffer B2 N units, output by the output process.

        a. This question what process? What kind of relationship between process constraints?

        b. Write synchronization algorithm processes signals between the operation amount and the PV

solution:

   a: input process, synchronous relationship between the treatment process, the output process, process.

Virtual Storage Manager

 

(2): 1, fifi algorithm is as follows 

To page: 001103122443 

Page fault rate is 6/12 = 50%

2, LRU algorithm is as follows

To page: 001103122443 

Page fault rate: 7/12 = 58.3%

3, POT algorithm is as follows

To page: 001103122443 

Page fault rate: 5/12 = 41.7

Guess you like

Origin www.cnblogs.com/ze-ze/p/11005083.html