Operating system consolidation common interview questions

(A) Please talk about are simple processes and threads as well as their differences.

  • Process is a program with certain functions run on one set of data on the activities of the process is an independent unit of system resource scheduling and allocation.
  • A thread is the entity process, is the basic unit of CPU scheduling and dispatching, which is smaller than the process of the basic unit can operate independently.
  • A process can have multiple threads, multiple threads can execute concurrently

If you are not familiar with the process or thread, I recommend reading: A simple explanation of processes and threads

(B) the manner of thread synchronization What?

 

  • Mutex: A mutex mechanism, only those with permission mutex thread have access to public resources. Because only a mutex object, it is possible to ensure that public resources can not be accessed simultaneously by multiple threads.
  • Semaphore: it allows the same time multiple threads access the same resources, but need to control the maximum number of threads the same time access this resource.
  • Event (signal): to maintain the operation of the multi-thread synchronization through a notification, but also facilitate the realization of multi-thread priority of the compare operations.

By two big correction, now deleted critical area. Thanks: @ Hypsizigus sauce @ Anyang

If you are not familiar way of thread synchronization, it is recommended reading: thread synchronization in several ways

Communication (c) the process of what?

Is divided into: a conduit system, the IPC (including message queues, semaphores, shared memory), SOCKET

The main conduit is divided into: general pipeline the PIPE  , flow conduit ( s_pipe ), named pipes ( name_pipe )

  • Pipe is half-duplex communication, only single data flow, and only the flow having a genetic relationship between the process, the process usually kinship parent and child processes
  • Named Pipes is half-duplex communication, which allows between unrelated processes to communicate
  • Semaphore is a counter used to control multiple processes access to resources, it is usually used as a locking mechanism.
  • Message queue is a linked list of messages, by message queue identifier stored in kernel.
  • Signal is a more sophisticated means of communication, an event used to notify the receiving process has occurred.
  • Shared memory is memory-mapped some other processes can be accessed, this shared memory created by a process, but multiple processes can access.

If you are on the process of communication are not familiar with, I recommend reading:  several inter-process communication

(D) What is a buffer overflow? What is the harm? What causes this?

Refers to a buffer overflow when the buffer exceeds the capacity of the computer itself when the buffer fills, an overflow of data coverage on a legitimate data.

Hazard following two points:

  • Program crashes, cause a denial of service Amount
  • Jump and execute some malicious code

The main cause of buffer overflow is not carefully check the user input program. 

If you want to learn a buffer overflow Recommended reading: buffer overflow attacks

(E) What is a deadlock? Conditions produced a deadlock?

In two or more concurrent processes, we can not move forward before if each process holds a resource but to wait for other processes to release it or they are now kept resources in this state does not change, saying the group processes had a deadlock. Popular talk is two or more processes indefinitely blocked each other in a state of waiting.

Deadlock four conditions (a condition is not satisfied, then no deadlock)

  • Mutually exclusive conditions: a resource can only be used by a process
  • Request to maintain conditions: when a resource request due process and blocked access to resources that have been kept hold
  • Not deprivation: the process of obtaining the resources, not completely finished before use, not to deprive
  • Loop wait condition: an annular end to end to form a plurality of processes waiting for a resource relationship between 

If the deadlock is not too familiar with the recommended reading: Method reasons for the deadlock and unlocking

(F) process, which has several state?

  • Ready: The process has received the required resources other than the processor, waiting for allocation of processor resources
  • Operating status: occupy processor resources to run the process in this state is equal to the number smaller than the number of CPU
  • Blocked: the process is waiting for some conditions, can not be performed until conditions are met 

If you installed for several state of the process and in the middle do not know, I recommend reading: three states and the conversion process

(Vii) paging and segmentation What is the difference?

 

  • Segment is a logical unit of information, which is divided according to the user's needs, so the segment is visible to users; physical page is a unit of information, in order to facilitate the management of the main memory and divided, is transparent to the user.
  • The segment size is not fixed, it has decided to complete the function; large page size is fixed, determined by the system
  • Section provides a two-dimensional address space to the user; page to provide users with a one-dimensional address space
  • Segment is a logical unit of information, and easy to share memory protection information, the protection is limited and shared pages.

If you still do not quite understand paging and segmentation, it is recommended reading: segmentation and paging

(Viii) operating system process scheduling strategy, which has several?

FCFS (FCFS), priority, round-robin, multiple feedback

If you want in-depth understanding of these types of scheduling policy Recommended reading: several commonly used operating system process scheduling algorithm 

(Ix) to talk about the synchronization process, which has several mechanisms.

Atomic operation, the semaphore mechanism, the tube spinlock, rendezvous, distributed system

If you want in-depth understanding of these types of mechanisms, Recommended reading:  several mechanisms synchronization process

(J) to talk about handling the basic strategy and common methods of deadlock.

The basic solution to the deadlock as follows: 

Prevent deadlock and avoid deadlock, deadlock detection, lifting deadlock 

A common strategy to address over four of the following: 

Ostrich policy, prevention strategies, tactics to avoid detection and to lift the deadlock 

If you deal with policy deadlock is not too familiar Recommended reading: cause and a necessary condition for deadlock + basic method to solve deadlock 

This article references and articles:

 

"1" operating system common interview questions summary - youngchang development blog

"2"  operating system interview questions - iWan

"3" several inter-process communication

"4" OS pen questions summary of major companies

"5" to solve the basic method deadlock

Guess you like

Origin blog.csdn.net/qq_36561697/article/details/94230560