Operating System concept Finishing

Source: Internet
Author: User

1. Process and Thread differences

A process is a program with a certain independent function on a data set on a running activity, it is the system for resource allocation and scheduling of an independent unit.

A thread is an entity of a process that is the basic unit of CPU dispatch and dispatch.

a) the process has a separate address space during execution, and multiple threads share the address space of the same process, which greatly improves the efficiency of the program .

b)

The processes and threads occupy resources as follows:

Resources that the process occupies Resources that the thread occupies
Address space
Global variables
Open a file
Child process
Signal Volume

Stack
Register
State
Program counter

Thread switching overhead is much less than the cost of process switching, and threads within the same process can share the process's code snippets, data segments, system resources (IO devices, files, and so on)

2. Process communication mode

Piping: Pipe
Pipelines can be used for communication between affinity processes, and well-known pipelines overcome the limitations of pipe without name, so that, in addition to having the functions of a pipeline, it allows communication between unrelated processes;

Signal (signal):
Signal is a more complex mode of communication, used to inform the receiving process that some event occurred, in addition to inter-process communication, the process can also send signals to the process itself; Linux in addition to supporting the UNIX early signal semantic function Sigal outside, Also support the semantics of the POSIX.1 standard signal function sigaction (in fact, the function is based on BSD, BSD in order to achieve a reliable signal mechanism, but also able to unify the external interface, with sigaction function to re-implement the signal function);

Message Queue: MSGGET/MSGSEND/MSGRECV
Message Queuing is a linked table of messages, including POSIX Message Queuing SYSTEMV Message Queuing. A process with sufficient permissions can add messages to the queue, and a process that is given Read permission can read the messages in the queue. Message queue overcomes the disadvantage that the signal carrying information is low, the pipeline can only carry the unformatted byte stream and the buffer size is limited.

Shared Memory: mmap
Allows multiple processes to access the same piece of memory space, is the fastest available IPC form. is designed for inefficient operation of other communication mechanisms. It is often used in conjunction with other communication mechanisms, such as semaphores, to achieve synchronization and mutual exclusion between processes.

Signal Volume (semaphore): Semget/semop
Primarily as a means of synchronizing between processes and between different threads of the same process.

Socket interface (SOCKET):
A more general inter-process communication mechanism that can be used for inter-process communication between different machines. Originally developed by the BSD branch of the UNIX system, it can now be ported to other Unix-like systems: both Linux and System V variants support sockets.

3. Thread Synchronous/Asynchronous

Synchronous and asynchronous attention is to the message communication mechanism (synchronous communication/asynchronous Communication)
The so-called synchronization is that when a * call is issued, the * call does not return until the result is obtained. But once the call returns, it gets the return value.
In other words, it is the result of the * caller actively waiting for this * call *.

Instead of async, the call is returned immediately after it isemitted , so no results are returned . In other words, when an asynchronous procedure call is made, the caller does not get the result immediately. Instead, the caller is notified by status, notification, or by a callback function to handle the call after the * call * is issued.

Blocking and non-blocking concerns the state of the program when it waits for the call result ( message, return value).

A blocking call means that the current thread is suspended until the call results are returned. The calling thread will not return until the result is obtained.
A non-blocking call means that the call does not block the current thread until the result is not immediately available.

4. Deadlock

5. Paging mechanism

Operating System concept Finishing

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.