Operating system notes,

Source: Internet
Author: User

Operating system notes,
Operating system notes

1. batch processing, time-sharing, and real-time are three basic types of Operating Systems

2. a distributed system is composed of several computers connected through an interconnected network. These computers can work independently and collaboratively. Allows you to manage resources in the system, dynamically allocate tasks, and run distributed programs in parallel.
A Distributed System is a more advanced network operating system and maintains all the functions of the network operating system.

3. Core and user
Core State (system state): You can execute all commands to access all registers and memory areas. Generally, the operating system kernel runs in this state.
User State: only some specified commands can be executed to access the specified register and memory area. Generally, the user program runs in this state.

4. Process Control Block (PCB): PCB is the cornerstone of concurrent program execution! Protects the on-site information of previous processes.

5. Primitive: an extension of machine commands. It consists of several machine commands to complete a program with specific functions.
Similar to machine commands, primitives are not allowed to be interrupted during execution. The execution of primitives is sequential rather than concurrent.
The primitive is an atomic operation, either completely or not.

6. A process family tree is a directed tree (for example, a node represents a process. A tree represents a family and the root node is the Ancestor of the family (Ancestor ). Set table items with family relationships in the PCB.
Child processes can inherit the resources owned by the parent process.
When the parent process is revoked, the child process must also be revoked.

Botnets and orphan processes in Linux.

7. Process Control primitives

Create and undo processes, and complete the transition between processes. Implemented by primitives with specific functions.
Process Creation primitive
Process withdrawal primitive
Blocking primitive
Wake-up primitive
Suspend primitive
Activation primitive

8. Create a primitive (Creation)

Creation primitive: the process in which the system creates a process control block PCB for the process and fills in the corresponding information items in the PCB.

9. Process Creation Flowchart

10. Process Creation (Create) Program

1 # include <stdio. h> 2 void main (int argc, char * argv []) {3 int pid; 4/* Call fork () to create a sub-process */5 pid = fork (); 6 if (pid <0) {/* creation failed! */7 fprintf (stderr, "Fork failed"); 8 exit (-1); 9} 10 if (pid = 0) {/* child process */11 printf ("I am a sub-process \ n "); 12} 13 else {/* parent process */14 printf ("I am a parent process \ n"); 15} 16 return 0 ;}

11. What is the difference between process suspension and blocking?

Process suspension: The system does not take any action after a certain period of time.
Process congestion: the process is temporarily unavailable because it is waiting for something (such as waiting for an I/O device). At this time, even if the processor is idle, the process cannot be used. There can also be multiple processes in the blocking state (also called blocking state, waiting state, and sleep state) in the system.

Process Composition
Program: describes the functions to be completed by the process. Is the material basis of the process.
Data: The object processed by a program.
Process control block PCB: used to describe all static and dynamic features of a process. The operating system can only perceive and manage processes through it. Each process has only one process control block.
Process control block content: the specific content of the PCB varies with different systems, generally including the following information:
· Process ID: uniquely identifies the name or code of a process.
· Process status: identifies a process as a running, ready, or blocked state.
· Process entity: indicates the position and size of the program part and data part of the process in the memory.
· Scheduling information (priority): determine the priority of the ready process to be converted to the running process
· Resource Information: Describes memory usage, peripherals usage, and other information.
· Field information: including the current value of the program counter, program status word, accumulators, and address change register
· Process Communication Information: used for inter-process communication

12. Differences between process suspension, congestion, and sleep

Blocking: A process is waiting for a certain resource, but cannot get it immediately. It must wait for other processes to release the resource to continue. If a passive process cannot get a time slice, the kernel switches to another process to run.
Sleep: Generally, the CPU is automatically discarded for a period of time.
Pending: the running time is reached, the kernel needs to schedule other processes to run, passive loss of CPU

13. semaphores:

Semaphore: A special integer variable proposed by Dijkstra, a Dutch scholar, in 1965.
Semaphore definition: 1 Data Structure + 2 basic operations
Struct semaphore
{
Int value; // record the number of wake-up operations
PCB * queue; // process waiting on the semaphore
}
P (semaphore s); // consumption wake-up operation
V (semaphore s); // generates a wake-up operation
The name of P comes from the Dutch proberen, that is, test.
The V name is also from Dutch verhogen (increment)

14. Differences between mutex and Synchronization

Synchronization is a more complex type of mutex, while mutex is a special type of synchronization.
Mutual Exclusion: A Resource allows only one visitor to access it at the same time, which is unique and exclusive. However, mutual exclusion cannot limit the access sequence of visitors to resources, that is, access is out of order.
Synchronization: the cooperation process coordinates the work of each other, controls the execution speed, and the resulting mutual cooperation and mutual wait constraints, that is, the operation is orderly.

15. AND semaphores

AND semaphore: To solve the deadlock problem caused by parallelism, The AND condition is introduced in the wait operation. The basic idea is to set all the critical resources required by the process during the entire operation, all processes are allocated at one time and released at one time after use. For the allocation of several critical resources, take the atomic operation mode: either all the resources are allocated to the process, or one of them is not allocated.

Semaphores are used to solve many synchronization and mutex problems. However, in the process of solving the problem, we also find that there are still some problems, such:
-In the case of producer and consumer problems, the positions of two P operations cannot be reversed;
-The deadlock in the dining question of philosophers.
The emergence of these problems promotes the generation of AND semaphores

16. Management Process

A process (Monitors, also known as a monitor) is a program structure. Multiple working threads in the structure form multiple subprograms (objects or modules) to access shared resources. These shared resources are generally hardware devices or a group of variables.
At a time point, only one thread can execute a subprogram of a management process. Compared with the concurrent program design that implements mutex access by modifying the data structure, the management process greatly simplifies the program design.

17. What are the differences between the management process, pipeline, and channel of the operating system!

1. Channel commands
-Channel commands
Specifies the operation of a device. Each channel command specifies an operation of a device. A Channel command generally consists of a command code, Data, primary address, transmission, number of bytes, and flag code.
-Channel Program
Is a set of channel commands that require the channel to perform an input and output operation, this group of commands constitute a channel program.
2. MPS queue mechanism
The output of the first command is used as the input of the second command. This connection technology is used.
3. Management Process
It represents the data structure of a shared resource, and a resource management program composed of a group of processes that operate on the shared data structure, which together constitute a resource management module of the operating system, we call it a management process.
18. Process Synchronization and communication

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.