First assignment: based on understanding of Linux

1. Process

   A process is a running activity of a program with certain independent functions, and it is also the smallest unit of resource allocation.

2. Organization of the process

2.1 Linear way

All PCBs are organized in a linear table, and the first address of the table is stored in a dedicated area of ​​the memory. Each search needs to scan the entire table, which is suitable for a small number of processes in the system.

2.2 Link method

The PCBs with the same state are linked into a queue with the link words in them, and the PCBs are stored in a continuous storage area.

2.3 Index method

The first address of each index table in the memory unit is also recorded in a dedicated unit in the memory, and the address in the PCB table of a certain PCB in a corresponding state is recorded by adding an index table.

3. Process conversion

3.1 Three-state model

The entire life cycle of a process from creation to revocation and death can be characterized by a set of states. According to the three-state model, the life cycle of a process can be divided into the following three process states: 
1. Running:
2. Ready state (ready): has the running conditions, waiting for the system to allocate the processor to run  3. 
Waiting state (blocked): does not have the running conditions, is waiting for the completion of an event

The process in the running state will enter the waiting state due to the occurrence of the waiting event. When the waiting event ends, the process in the waiting state will enter the ready state, and the scheduling policy of the processor will cause the switching between the running state and the ready state.

The specific reasons for the process state transition are as follows:

  • Running state—→waiting state: waiting to use resources; such as waiting for peripheral transmission; waiting for manual intervention.
  • Waiting state—→ready state: resources are satisfied; such as the end of peripheral transmission; manual intervention is completed.
  • Running state - → ready state: the running time slice is up; there is a higher priority process.
  • Ready state—→running state: select a ready process when the CPU is idle.

3.2 Five-state model

In an actual system, the state of the process and its transitions are more complicated than those described in the previous section, such as the introduction of special
new  states (new) and termination states (exit).


The state transition diagram is shown below: 


 

The build state corresponds to the state in which the process has just been created. Creating a process is a two-step process, 
1. creating the necessary management information for a new process, 
2. making the process ready. At this point, the process will be in a new state, it has not been submitted for execution, but is waiting for the operating system to complete the necessary operations to create the process. It should be noted that the operating system will sometimes delay the submission of new ecological processes based on system performance or main memory capacity constraints.

The specific reasons for the process state transition are as follows:

  • NULL—→New state: Execute a program and create a child process.
  • New state—→ready state: When the operating system has completed the necessary operations for process creation, and the current system performance and virtual memory capacity allow it.
  • Running state - → Termination state: When a process reaches the natural end point, or an insurmountable error occurs, or it is terminated by the operating system, or it is terminated by other processes that have the right to terminate.
  • Termination state—→NULL: Complete the aftermath operation.
  • Ready State - → Terminated State: Not shown in the state transition diagram, but some operating systems allow the parent process to terminate the child process.
  • Waiting state - → Terminating state: Not shown in the state transition diagram, but some operating systems allow the parent process to terminate the child process.

 4. How processes are scheduled

4.1 Round Robin Scheduling
 
Each process is assigned a quantum (quantum), that is, the process is allowed to run in this time period, and if the process is still running at the end of the quantum, the CPU is deprived and assigned to another process. If the process blocks or ends before the time slice ends, the CPU switches immediately.
 
The setting of the time slice length is very important in round-robin scheduling, because switching from one process to another process takes a certain amount of time - including saving and loading register values ​​and memory images. Updating various tables and lists, clearing and reloading in-memory caches, etc. Process switching is also sometimes referred to as context switching. Setting the time slice too short will result in excessive process switching. Reduces CPU efficiency; setting it too long may result in longer response times for short interactive requests.
 
4.2 Priority Scheduling
The implicit assumption of round-robin scheduling is that all processes have the same priority. By dynamically or statically setting priorities for processes, we can achieve priority scheduling, and processes with higher priorities will run first.
 
To prevent high-priority processes from running indefinitely, the scheduler can lower the priority of the current process at the end of each clock cycle. If this action causes the priority of the process to be lower than the next highest priority process. process switching. One possible approach is that each process can be given a maximum time slice that is allowed to run. When this time slice is exhausted, the next highest priority process gets a chance to run.
 
 
5. Understanding of linux
Since the Linux kernel is mostly written in C language and adopts the portable Unix standard application programming interface, it supports system platforms such as i386, Alpha, AMD and Sparc, as well as from personal computers to mainframes, even including Various hardware devices including embedded systems.

Different from other operating systems, after installing the Linux system, some office software, graphics processing tools, multimedia playback software and network tools commonly used by users do not need to be installed. For program developers, Linux is a good operating platform. The Linux software package includes a variety of programming languages ​​and development tools, such as gcc, cc, C++, Tcl/Tk, Perl, Fortran77, etc. .

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325143288&siteId=291194637