Processes and threads for computer operating systems

Source: Internet
Author: User

Operating System

time-sharing system
      A computer can connect multiple user terminals simultaneously due to the increasing CPU speed and the use of timeshare technology. And each user can use the computer on their own terminal, as if they were monopolizing the machine.
      Time Sharing technology: The operating time of the processor is divided into a very short period, according to the time slice in turn the processor assigned to the use of the online operation.
      Features:
(1) multiplexing. Several users use a single computer at the same time. Microscopic view is that each user takes turns to use the computer, macro view is the user work in parallel.
(2) interactivity. The user can further make a new request to the system based on the response of the system to the request. This can make the user and the system of Man-machine dialogue work way, obviously different from batch processing system, therefore, time-sharing system is also called interactive system.
(3) independence. Users can operate independently of each other and interfere with each other. The system guarantees the integrity of the operation of each user program and does not confuse or destroy each other.
(4) timeliness. The system can respond to the user's input in a timely manner. One of the main indicators of CTSS performance is response time, which refers to the time it takes to issue commands from the terminal to the system to answer. The main features of the
real-time system
Real-time operating system:
(1) Timely response. The process of receiving, analyzing and sending each information must be completed within strict time limits.
(2) high reliability. Need to take redundant measures, dual-machine system before and after work, but also include the necessary confidentiality measures.


Tick-now popular PC, the server is the use of this mode of operation, that is, the operation of the CPU divided into several time slices to deal with different operational requests Linux system
Real-time-generally used in single-chip microcomputer, PLC, etc., such as elevator up and down CONTROL, Real-time processing for keystrokes and other actions

Unix operating system is a universal multi-user tick-sharing operating system
operating system is a coordination, management and control of computer hardware resources and software resources of the program.
What the operating system does:
    1: Hides ugly, complex hardware interfaces, provides a good abstraction interface
    2: Manages, schedules processes, and makes multiple processes competitive with hardware

concept and characteristics of the process

Definition of the process

before you talk about the process, you must first understand what the program is: program (program) is a collection of command sequences written in computer language to achieve a specific goal or to solve a specific problem, and must be python.

    • A process is a process of executing a program.
    • A process is the activity that occurs when a program and its data are executed sequentially on the processing machine.
    • A process is a process that runs on a data set by a program that has a separate function, which is an independent unit of the system for resource allocation and scheduling.

Parallelism and concurrency of processes
Parallel: Parallel is the execution of both, such as running, two people are running forward; (resources sufficient, such as three threads, quad-core CPUs)
Concurrency: Concurrency refers to the limited resources of the situation, the two alternate use of resources, such as a section of the road (single-core CPU resources) at the same time only one person, a after a period, let b,b use to continue to a, alternating use, the purpose is to improve efficiency.

Process synchronous and asynchronous
The so-called synchronization is the completion of a task needs to rely on another task, only wait for the task to be relied upon to complete, the dependent task can be counted, this is a reliable task sequence. Either success succeeds, failure fails, and the state of the two tasks remains the same.
The so-called asynchronous is not required to wait for the task to be relied upon to complete, but to inform the dependent task to complete what work, dependent on the task is also immediately executed, as long as the completion of their own complete task, even if completed. As to whether the dependent task is ultimately completed, the task that relies on it cannot be determined, so it is an unreliable task sequence.

Characteristics of the process

A process is caused by concurrent execution of multiple programs, and it is a two distinct concept from a program. The basic characteristic of the process is to compare the sequential execution of individual programs with the basic requirements of process management.

    1. Dynamic: The essence of the process is the process of a program in a multi-channel program system, the process is dynamic generation, dynamic extinction.
    2. Concurrency: Any process can execute concurrently with other processes
    3. Independence: The process is a basic unit that can operate independently, and it is also an independent unit for allocating resources and dispatching.
    4. Asynchrony: Because of the inter-process constraints, the process has a discontinuity of execution, that is, the process at its own independent, unpredictable speed ahead
    5. Structure characteristic: The process consists of three parts, the program, the data and the process Control block.

Many different processes can contain the same program: a program that forms different processes in different datasets and can get different results, but the program cannot change during execution.

Transition of process state

Process in its life cycle, due to the mutual constraints between the processes in the system and changes in the operating environment of the system, so that the state of the process is also constantly changing (a process will go through several different states). Typically there are five states of the process, the first three being the basic state of the process.

1) Running status: The process is running on the processing machine. In a single processor environment, at most one process at a time is in the running state.

2) Ready state: The process is already in the ready to run state, i.e.The process obtains all the required resources except the processor, which can be run once the processor is available.

3)Blocking state, also known as a wait state: a process is waiting for an event to pause, such as waiting for a resource to be available (not including a processor) or waiting for input/output to complete. even if the processor is idle, the process cannot run.

4) Creation Status: The process is being created and has not yet been transferred to the ready state. Creating a process typically requires multiple steps: First apply for a blank PCB and fill in some information about the control and management process to the PCB, and then the system allocates the resources necessary for the process to run, and finally transfers the process to a ready state.

5) End Status: The process is disappearing from the system, which may be the process is terminated gracefully or other reasons interrupt the exit run. When the process needs to end the run, the system must first set the process to an end state, and then further process the resource release and recycling work.

Note Difference Readiness and wait states: the readiness State means that the process is only missing processors and executes as soon as the processor resources are obtained, while the wait state refers to the process requiring additional resources (except the processor) or waiting for an event. The reason for dividing the processor and other resources is because in the time-slice rotation mechanism of the timeshare system, the time slices divided by each process are several milliseconds. In other words, the process gets the processor time is very short and very frequent, the process in the process is actually frequently converted to the ready state, while other resources (such as peripherals) use and allocation or the occurrence of an event (such as the completion of I/O operations) corresponds to a relatively long time, The number of transitions to the wait state is also relatively small. In this view, the readiness and wait states are two completely different states in the process life cycle, which clearly needs to be differentiated.



Conversion of five states


Ready State----->>> Running state: When the process in the ready state is dispatched, the processor resource (dispatch processor Time slice) is obtained, and the process is converted from ready to run state.

Running state----->>>Ready state: The running process will have to give up the processor after the time slice is exhausted, so the process transitions from the running state to the ready state. Also, in a stripped-down operating system, when a higher-priority process is in place, the level of dispatch translates the process being executed into a ready state for higher-priority processes to execute.

Running state----->>>Blocking state: When a process requests the use and allocation of a resource (such as a peripheral) or waits for an event to occur (such as the completion of an I/O operation), it transitions from the running state to the blocking state. The process requests the operating system to provide services in the form of a system call, which is a special form of invoking the operating system kernel procedure by the running user-state program.

Blocking state----->>>Ready state: When a process waits for an event to arrive, such as the end of an I/O operation or the end of an interrupt, the interrupt handler must convert the state of the corresponding process from a blocking state to a ready state.

Processes in Python

process creation and completion
fromMultiprocessImportprocessprocess (Target= The function name of the child, args=parameters)def __init__(Self, Group=none, Target=none, Name=none, args= (), kwargs={}): emphasize:1need to use keywords to specify parameters2. args Specifies the positional parameter passed to the target function, which is a tuple form and must have a comma parameter description:1The group parameter is not used and the value is always none2target represents the calling object, which is the task to be performed by the child process3 args represents the positional parameter tuple of the calling object, Args= (1, 2,'Egon',)4 Kwargs represents the dictionary of the calling object, kwargs={'name':'Egon',' Age': 18}5 name for child process



Processes and threads for computer operating systems

Related Article

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.