Operating System FAQs

Source: Internet
Author: User

1. What is process and thread? What's the difference?

A process is a program with a certain independent function about a single run activity on a data set, a process that is an independent unit of the system's resource allocation and scheduling. A thread is an entity of a process that is the basic unit of CPU dispatch and dispatch, which is a smaller unit that can run independently than a process. The thread itself does not own the system resources, it has only a few resources (such as program counters, a set of registers and stacks) that are essential in the run, but it can share all the resources owned by the process with other threads belonging to one process. One thread can create and revoke another thread, which can be executed concurrently between multiple threads in the same process.

The difference between a process and an application is that the application is stored as a static file in the storage space of the computer system's hard disk, while the process is a system resource management entity maintained by the operating system under dynamic conditions.

2. How is the memory under Windows managed?

Windows provides 3 ways to manage Memory: virtual memory, which is best used to manage large objects or arrays of structures, and memory-mapped files that are best used to manage large data streams (typically from files) and to share data between multiple processes running on a single computer; memory stacks, Ideal for managing large numbers of small objects.

Windows manipulates memory in two layers: physical memory and virtual memory.

Where physical memory is managed by the system and does not allow direct application access, only one 2G address space is visible to the application, and memory allocations are made through the heap. For each process has its own default heap, when a heap is created, the corresponding size of the address block is preserved through virtual memory operations (the system consumes very little of the actual memory). When allocating a piece of memory on the heap, the system finds a free block in the Address table of the heap (if it is not found, and the heap creation attribute is extensible, the heap size is expanded), and the physical object (on physical memory or on the swap file of the hard disk) is submitted for all memory pages contained in the free block. Upon submission, the system will uniformly allocate memory for all processes, and if there is insufficient physical memory, the system attempts to place a portion of the process temporarily inaccessible to the swap file to free up some of the physical memory. When memory is freed, only the page that resides in the heap is unblocked (the corresponding physical object is dismissed), and the address space continues to be preserved.

If you want to know if an address is occupied/can be accessed, simply query the virtual memory state of this address. If it is a commit, you can access it. If it is reserved, or not retained, a software exception is generated. In addition, some memory pages can set various properties. If it is read-only, writing to memory also produces a software exception.

3, Windows message scheduling mechanism is?

A) instruction queue; B) instruction stack; C) message queue; D) message stack

Answer: C

The order in which message queues are processed. First of all, Windows is not processed in the order of first in and out of the queue, but with a certain priority. The priority is implemented through the status flags of the message queue. First, the highest priority is the message (via SendMessage) that other lines Cheng over, followed by processing the enlistment message queue message, processing the QS_QUIT flag again, processing the virtual input queue, processing WM_PAINT, and finally Wm_timer.

4. Describe the basic characteristics of real-time system

Achieve specific tasks, real-time and reliability, in a specific time period.

The so-called "real-time operating system", in fact, refers to the operating system, its various resources can be dynamically allocated as needed. Because various resources can be dynamically allocated, their ability to process transactions is stronger and faster.

5. Features of interrupts and polling

The way the program polls the I/O devices is a way to manage the I/O devices of the early computer system. It periodically turns to all kinds of equipment and asks if there are any processing requirements. After a turn of inquiry, if requested, it will be dealt with. After processing the I/O device requirements, the processing machine returns to work. Although polling takes time, polling is much faster than I/O devices, so there is generally no problem that cannot be handled in a timely manner. Of course, there is a limit to the number of input that can be dealt with faster processors. And, after all, the program polling takes up a considerable portion of CPU processing time, so program polling is a less efficient way, and is rarely used in modern computer systems.

program interruption is usually referred to as interruption, refers to the CPU in the normal operation of the process, due to pre-arranged or occur a variety of random internal or external events, so that the CPU interrupts the running program, and go to the response of the service program to deal with.

Polling-low efficiency, long wait time, not high CPU utilization.

Interrupt--Easy to miss some problems, high CPU utilization.

6. What is a critical section? How to resolve conflicts?

The program that accesses critical resources in each process is called a critical section, allowing only one process to enter the critical section at a time, and not allowing other processes to enter.

(1) If a number of processes require access to an idle critical section, only one process is allowed to enter at a time;

(2) At any time, no more than one process is in the critical area. If a process has entered its own critical section, all other processes attempting to enter the critical area must wait;

(3) The process of entering the critical area should be exited within a limited time so that other processes can enter their critical areas in time;

(4) If the process does not enter its own critical section, you should give up the CPU, to avoid the process "busy" phenomenon.

7, talk about the sub-paragraph and paging

Page is the physical unit of information, paging is for the realization of discrete distribution, to reduce the amount of memory, increase the utilization of memory, or paging is simply due to the need for system management, not the needs of users.

A segment is a logical unit of information that contains a set of information that is relatively complete in its meaning. The purpose of segmentation is to be able to better meet the needs of users.

The size of the page is fixed and determined by the system, the logical address is divided into page number and in-page address two parts, is implemented by the machine hardware, so that a system can only have one size of the page. The length of the segment is not fixed, it is decided by the user to write the program, usually by the editor in the source program editing, according to the nature of the information to be divided.

Paging Job address space is one-dimensional, that is, a single linear space, programmers only need to use a memory, can represent an address. The job address space of the segment is two-dimensional, when the programmer identifies an address, it needs to give both the segment name and the address in the paragraph.

8. Say what you know about how to keep the process in sync?

The main methods of inter-process synchronization are atomic operation, semaphore mechanism, spin lock, enhancement, rendezvous, distributed system and so on.

9. Commands commonly used in Linux

Show file directory command ls as LS

Change the current directory command CD such as Cd/home

Create subdirectories mkdir such as mkdir Xiong

Delete subdirectories command rmdir such as Rmdir/mnt/cdrom

Delete File command rm like Rm/ucdos.bat

File copy command CP such as Cp/ucdos/fox

Get help info command man like man ls

Displays the contents of the file less MWM.LX

Redirect and pipe type such as type Readme>>direct, append the contents of the file Readme to the text direct

10. What are the properties of Linux files? (Total 10 people)

-rw-r–r– that is the permission symbol, the total is---these few bits.

The first short horizontal is the file type identifier:-Represents a normal file, C denotes a character device (character), B represents a block device (blocks), D represents a directory (directory), and L represents a linked file (link) , followed by the first three consecutive short Shan user rights bit (user), the second three consecutive short Shan group permission bit (group), the third three consecutive short Shan other permission bits (other). Each permission bit has three permissions, R (Read permission), W (Write permission), and X (Execute permission). If each permission bit has permission to exist, then the full permission is:-rwxrwxrwx;

The permissions can be set with the chmod command, with the format bit: chmod ugoa+/-/=rwx filename/directory. For example:

A file AAA has full NULL permissions---.

chmod U+RW aaa (to set read and Write permissions to user permissions, which are represented by:-rw---)

chmod g+r aaa (Sets the permissions for the group to be readable and its permissions are expressed as:--r–-)

chmod UGO+RW aaa (for users, groups, other users or groups to set permissions for read-write, permissions expressed as:-rw-rw-rw-)

If AAA has full permissions-rwx rwx rwx.

chmod u-x aaa (remove user-executable permissions, rights expressed as:-rw-rwx rwx)

If you want to give the AAA permission to set-rwx r-x r-x, the command is:

chmod U=rwx,go=rx AAA

11. What is the role of the makefile file?

There are countless source files in a project, which are placed in several directories by type, function and module. Makefile defines a set of rules to specify which files need to be compiled first, which files need to be compiled, which files need to be recompiled, and even more complex functional operations. Because makefile is like a shell script, it can also execute commands from the operating system. The advantage of makefile is that--"automated compilation". Once written, only one make command is required, the entire project is automatically compiled, greatly improving the efficiency of software development. Make is a command tool that is a command tool that interprets instructions in makefile. In general, most Ides have this command, such as: Delphi's Make,visual C + + Nmake,linux under GNU make. Thus, Makefile has become a compilation method in engineering.

12, the physical layer of the OSI Layer1, link layer Layer2, Network layer Layer3 task.

Network layer: Select the most appropriate path for the message or packet through the communication subnet through the routing algorithm.

Link layer: Through a variety of control protocols, the error of the physical channel into error-free, can reliably transmit data frame data link.

Physical layer: The transmission medium is used to provide the physical connection to the data link layer, which realizes the transparent transmission of the bit stream.

13. What is interruption? What does the CPU do when it interrupts?

Interrupts are any unusual or unexpected processing events occurring within the system during the execution of the computer, causing the CPU to temporarily interrupt the currently executing program and go to execute the appropriate event handler. The process of executing or scheduling a new process is returned at the end of the pending processing.

14. Do you know the contents of the operating system are divided into several pieces? What is virtual memory? What's his relationship with main memory? Does memory management belong to the contents of the operating system?

The main components of the operating system: process and thread management, storage management, device management, file management. Virtual memory is some system page files, stored on disk, each system page file size is 4K, physical memory is also paged, each page size is 4K, so that virtual page files and physical memory pages can correspond, in fact, virtual memory is used for physical memory of the temporary storage disk space. Page files are memory pages, physical memory is called a physical page, the page file on disk is called Virtual page, physical page + virtual page is the sum of all the page files used by the system.

15. Does the thread have the same stack? Does the DLL have a separate stack?

Each thread has its own stack.

Does the DLL have a separate stack? The question is not answered, or whether the question itself is problematic. Because the code in the DLL is executed by some threads, only the thread owns the stack. If the code in the DLL is called by a thread in the EXE, does this mean that the DLL does not have a separate stack? If the code in the DLL is executed by a thread created by the DLL itself, does it say that the DLL has a separate stack?

The above is the stack, if for the heap, each DLL has its own heap, so if it is dynamically allocated from the DLL memory, preferably removed from the DLL, if you allocate memory from the DLL, and then in the EXE, or another DLL to delete, it is likely to cause the program to crash.

16. What is 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.

Hazard: In the current network and Distributed system security, the widespread use of more than 50% is buffer overflow, the most famous example is the 1988 exploit the Fingerd vulnerability of the worm. In the buffer overflow, the most dangerous is the stack overflow, because the intruder can take advantage of the stack overflow, when the function returns to change the address of the return program, let it jump to any address, the harm one is the program crashes caused by the denial of service, the other is to jump and execute a piece of malicious code, such as getting the shell, Then do whatever you have. By writing content beyond its length to the program's buffer, the buffer overflows, thereby destroying the program's stack and allowing the program to execute other instructions in order to achieve the purpose of the attack.

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

17. What is a deadlock? What are the conditions? How to avoid deadlocks?

The concept of deadlock: in two or more concurrent processes, if each process holds a resource and waits for another process to release it or the resources that they now maintain, it cannot advance until this state is changed, saying that the set of processes has a deadlock. In layman's terms, it is a state in which two or more processes are blocked indefinitely and wait for each other.

The main causes of deadlocks are:? Insufficient system resources;? Process advance sequence illegal.

The necessary conditions for creating a deadlock:

(1) Mutual exclusion (mutualexclusion), a resource can only be used by one process at a time;

(2) cannot seize (nopreemption), the process has obtained the resources, before the use of the end, can not forcibly deprived;

(3) Occupy and Wait (hold andwait), when a process is blocked by a request for resources, the acquired resources are kept in place;

(4) Annular Waiting (circularwait), a kind of cyclic waiting resource relationship between several processes is formed.

These four conditions are necessary for the deadlock, as long as the system has a deadlock, these conditions must be established, and as long as one of the above conditions is not satisfied, there will be no deadlock.

Deadlock and prevention: Understanding the cause of deadlocks, especially the four necessary conditions that generate deadlocks, can be avoided, prevented, and unlocked in the greatest possible way. Therefore, in the system design, process scheduling and other aspects of how to not let these four necessary conditions to set up, how to determine the rational allocation of resources algorithm, to avoid the process of permanent occupation of system resources. Also, prevent the process from consuming resources while it is in a wait state. Therefore, the allocation of resources should be given reasonable planning.

Deadlock processing strategy: Ostrich strategy, prevention strategy, avoidance strategy, detection and recovery strategy.

Operating System FAQs

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.