Common face questions of operating system

Source: Internet
Author: User

(a) Please briefly say the differences between the process and the threads and their respective.

    • A process is a program with a certain function about a running activity on a data set, a process that is a separate unit of the system for resource scheduling and allocation.
    • A thread is the entity of a process, the basic unit of CPU dispatch and dispatch, and a smaller unit that can run independently than a process.
    • A process can have multiple threads, and multiple threads can execute concurrently

If you are unfamiliar with processes or threads, it is recommended to read: A simple explanation of processes and threads

(b) What are the ways of thread synchronization?

    • Mutex: With a mutex mechanism, only the thread that owns the mutex has access to the public resource. Because there is only one mutex object, you can ensure that the public resources are not accessed concurrently by multiple threads.
    • Semaphore: It allows multiple threads to access the same resource at the same time, but needs to control the maximum number of threads accessing this resource at the same time.
    • Event (signal): Through the way of notification operation to maintain multi-threaded synchronization, but also convenient to achieve multi-thread priority comparison operation.

The critical section has now been removed by two digits. Thank you: @ true kee sauce @ Anyang

If you are not familiar with the way threads are synchronized, it is recommended to read: Several ways of thread synchronization

(iii) What are the communication modalities of the process?

Mainly divided into: pipeline, System IPC (including message queue, semaphore, shared storage), SOCKET

Pipelines are mainly divided into: common pipe pipes, flow pipelines (s_pipe), Named Pipes (name_pipe)

    • A pipeline is a half-duplex mode of communication in which the data can only flow individually and can only flow between the processes that are related, and the affinity of the process is usually the parent-child process
    • A named pipe is also a half-duplex communication mode that allows non-affinity interprocess communication
    • A semaphore is a counter that controls the access of multiple processes to a resource, which is usually used as a locking mechanism.
    • Message Queuing is a list of messages that are stored in the kernel and identified by message queue identifiers.
    • A signal is a more sophisticated form of communication that notifies the receiving process that an event has occurred.
    • Shared memory is the mapping of memory that can be accessed by other processes, which is created by a process, but can be accessed by multiple processes.

If you are not familiar with the way the process communicates, it is recommended to read: Several ways of communicating between processes

(d) What is a buffer overflow? What's the harm? What is the reason?

A buffer overflow is when the computer fills the buffer with data that exceeds the capacity of the buffer itself, and the overflow data is overwritten with legitimate data.

The hazard has the following two points:

    • program crashes, resulting in denial of service
    • Jump and execute a piece of malicious code

The main reason for the buffer overflow is that the user input is not checked carefully in the program.

If you want to learn more about buffer overflow, it is recommended to read: Buffer overflow attack

(v) What is a deadlock? What are the conditions for a deadlock?

In two or more concurrent processes, if each process holds some kind of resource and waits for other processes to release it or the resources that they are currently holding, they cannot move forward until this state is changed, saying that the set of processes has a deadlock. Popular speaking is a state in which two or more processes block indefinitely and wait for each other.

Four conditions for deadlocks (if one condition is not true, no deadlock will occur)

    • Mutex condition: A resource can only be used by one process at a time
    • Request and hold condition: When a process is blocked by a request for resources, it remains in place of the acquired resources
    • Non-deprivation: the resources acquired by the process cannot be forcibly deprived until it is fully used
    • Cyclic wait condition: A circular waiting resource relationship between several processes to form a tail-to-toe phase

If you are not too familiar with deadlocks, it is recommended to read: Causes of deadlocks and how to unlock them

(vi) What are the various states of the process?

    • Ready state: The process has obtained the required resources other than the processor, waiting for the allocation processor resources
    • Running state: Consumes processor resources running, the number of processes in this state is less than or equal to the number of CPUs
    • Blocking state: The process waits for a condition that cannot be executed until the condition is met

If you are not familiar with the status of the process and the middle of the reload, it is recommended to read: three states and transitions of the process

(vii) What is the difference between pagination and segmentation?

    • Paragraph is the logical unit of information, it is divided according to the needs of the user, so the segment is visible to the user, the page is the physical unit of information, is to manage the main memory of the convenience and division, the user is transparent.
    • The size of the segment is not fixed, the function that it completes is decided; The page is fixed in large size, determined by the system
    • The segment provides a two-dimensional address space to the user, and the page provides the user with a one-dimensional address space
    • Segments are logical units of information, facilitate storage protection and sharing of information, and restrict the protection and sharing of pages.

If you don't know much about pagination and fragmentation, it's recommended to read: sections and pagination

(eight) What kinds of process scheduling policies are in the operating system?

FCFS (first come first service), priority, time slice rotation, multi-level feedback

If you want to know more about these scheduling strategies, it is recommended to read: several common operating system process scheduling algorithms

(ix) Say what kinds of mechanisms are in process synchronization.

Atomic operation, semaphore mechanism, spin lock enhancement, rendezvous, distributed system

If you want to learn more about these mechanisms, it is recommended to read: Several mechanisms of process synchronization

(10) Talk about the basic strategies and common methods of deadlock handling.

The basic methods for resolving deadlocks are as follows:

Prevents deadlocks, avoids deadlocks, detects deadlocks, unlocks deadlocks

The most common strategies for solving more than four are as follows:

Ostrich strategy, prevention strategy, avoidance strategy, detection and release deadlock

If you are not too familiar with the handling strategy of deadlocks, recommend reading: Causes and prerequisites for deadlocks + basic methods for resolving deadlocks

This article was reprinted from: 79489748

Common face questions of operating system

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.