Interview content-Operating System

Source: Internet
Author: User

Interview content-Operating System

1. What kind of States are involved in the process, the status transition diagram, and the events that cause the conversion.

2. Differences between processes and threads.

The thread is introduced to reduce the time-space overhead of the program during execution of the ice method, so that the OS has better concurrency, which further improves the resource utilization and system throughput.

Comparison:

(1) scheduling: in traditional OS, the basic unit of UFIDA resources and the basic unit of independent scheduling and dispatching are processes. In the OS that introduces threads, the thread is the basic unit of System Scheduling and dispatching, and the process is the basic unit of resource ownership. (2) Owning resources: The basic unit of UF Resources in the two operating systems is process. In addition to the essential resources in the running process, a thread basically does not own resources, but it can access the resources of its subordinate processes. (3) concurrency: In the OS of the introduced thread, not only can the process be executed concurrently, but also can be executed concurrently between multiple threads of the same process, so it has better concurrency. (4) system overhead: resources must be allocated or recycled by the system when a process is created or withdrawn. Because multiple threads belonging to the same process share the same space and address, and all opened files of the process, the implementation of synchronization and communication between them is more convenient than the process.

(1) shared storage system:

① Communication mode based on the shared data structure. (This communication method is offset and only applies to passing a relatively small amount of data)

② Communication method based on the shared storage area: in order to transmit a large amount of data, a shared storage area is allocated in the storage area, all processes can communicate by reading or writing data to the shared storage area and transmit a large amount of data.

(2) message transmission system:

① Direct communication mode-message buffering: Process message buffering queues are used. message senders directly place messages in the receiver's message buffering queues.

② Indirect communication mode: Use the intermediary-mailbox and post office to deliver the mail; the sending process sends the message to the mailbox, and the receiving process extracts the message from the mailbox.

(3) pipeline communication:

The so-called "Pipeline" refers to an open shared file, also known as pipe file, linked to the Second Brother process. The sending process sends a large amount of data to the pipeline in the form of a pipeline stream; the receiving process reads data from the pipeline as needed.

4. Several Methods of thread synchronization. (Be sure to write questions about producers and consumers to fully understand them)

(1) critical section

When multiple threads access a dedicated shared resource, you can use a critical area object. The thread in the UFIDA critical section can access the protected resources or code segments. If other threads want to access the code, the thread is suspended until the thread in the UFIDA critical section gives up the critical section. Specific Application Methods: ① define the critical section object CcriticalSection g_CriticalSection; ② obtain the critical section object g_CriticalSection.Lock () before accessing the shared resource (code or variable); ③ After accessing the shared resource, the critical section object is discarded, g_CriticalSection.Unlock ();

(2) Events

Event mechanism allows a thread to actively wake up another thread to execute a task after processing a task. For example, in some network applications, A thread such as A is responsible for listening to the communication port, and another thread B is responsible for updating user data and using the event mechanism, there are two types of thread A Cevent objects: manual events and automatic events.

The automatic event object is automatically returned to the non-signal state after being released by at least one thread;

Human Event object. After obtaining the signal, release the available thread, but know to call the member function ReSet ();

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.