2.20 operating system notes

Clock replacement algorithm

Is a compromise of FIFO and LRU algorithm, FIFO is not in the list do any treatment, directly to the first, smaller overhead, missing the maximum number of pages, clock replacement algorithm is a medium cost, medium number of missing pages, LRU is less but to implement overhead is relatively large

Working mechanism: FIFO order traversal to find the time to stay the longest

     LRU list is ranked according to the last access time of ordering, the head was recently accessed from most long tail is then inserted into it to find, to find the missing page, then the last to be replaced, and then placed header

     Clock a circular list, direct traversal, playing tag on the list, a site visit, when the missing pages If the current access is a bit hit 0, then look to the next, that is, to find the replaced 0, 1 mark

As in the worst case, the efficiency of the three algorithms, that is not seen every time

FIFO has delady phenomenon, that is a big change memory space to store pages, but also more of the missing page number

The most unusual algorithm: Use to compare the number of visits, shortcomings, if a large number of the visit, even if the latter does not access will not be replaced

 

Full replacement algorithm

Because locality replacement algorithm is not well controlled difference fetched, you might add this section of your page and you will significantly reduce the disruption, some segments will get a few pages is enough, is dynamic

Working set and permanent set

Ideally, the working set is present in the page memory

Permanent set is the reality that exist in memory page

This time the resident set> = working set interrupt less

Otherwise the jitter problem, many interrupt occurs, that is, the physical page allocation process which is not enough, the reason is because more and more running processes, then reduce the physical page

 

Working Set replacement algorithm: First, given the size of the window, and then if a page had the window size has not been replaced with out access to

Page fault rate replacement algorithm: two page fault, the memory is not in the middle of it replaced out access

 

 

process

Process is actually a program to dynamic execution of data (process consists of three parts PCB program data), the process space with its own stack, code area, data, stack, etc., the process control block is responsible for operations in the kernel of

Process states are waiting for the end to create a ready to run five states

Creation is not finished in time allocation of state resources

Ready is the allocation of resources over, just waiting to run on it

Run is a running process

Wait is to apply IO device, the system of some services and the like, this time the process is not running, only in a wait state

End is destruction process

There have pointed to Create -> Ready Ready -> Run to run -> Ready (time slice runs out) Run -> wait (IO event) wait -> Ready (waiting for an event has occurred)

To save memory space, opened a suspended state, there are ready and waiting to hang suspended, and ready and waiting for the difference is the location is in the external memory to make room for other processes, the general condition is likely to hang ordinary higher priority like

Suspend the ordinary is the current lower priority than

 

Thread

Because of isolation between processes, and share the message up too much overhead, so they put forward the concept of threads, the thread is to achieve concurrent execution

A thread is in the internal process, the process contains multiple threads, the same process threads can share the space, that they share with each other the code area, data, heap these resources, then there is its own stack and register resources

After threading units proposed, the process became the allocation of CPU resources, it has become the thread scheduling unit

Thread advantages:

A process can be multiple threads simultaneously

You can execute concurrently between threads

y individual threads can share resources

Thread Disadvantages:

A thread might lead to the collapse of all threads in the process crashes, sharing resources between threads reasons

The difference between threads and processes:

Process is a resource allocation unit, the thread is CPU scheduling unit

Process contains a complete resource, only the registers and stack thread

Time overhead and space overhead is less than the thread process (because of less thread resources required, because the sharing of resources between threads, switching does not require kernel communication)

User threads : the user thread is in the process some of the user's own operation, store thread TCB in the process, but the kernel is not fully known

Benefits: do not rely on the kernel, maintained by the thread library functions implemented in user space threads, thread switching speed fast in the process (because they do not involve the kernel, user mode)

Disadvantages: If the thread is blocked, the process to plug does not support preemptive thread allocation of time slices is too small

Summary: The main disadvantages are based on kernel does not know the benefits of page-based kernel does not know

Kernel threads : the TCB into the kernel control, and then the process of generating the mapping relationship, so the thread and the kernel is one to one relationship, what time slice preemption is not a problem

Disadvantages: involve core, large overhead

Guess you like

Origin www.cnblogs.com/Lis-/p/12334451.html