Basic Operating System Knowledge

Source: Internet
Author: User

Basic Operating System Knowledge

I. Process Management

1. What are the differences between processes and threads?

A process is a running activity of a program that closes a dataset. It is an independent unit for the system to allocate and schedule resources.

A thread is an entity of a process and the basic unit of CPU scheduling and allocation. A thread basically does not have system resources.

The differences are as follows:

A. a thread must belong to only one process. a process can have multiple threads and at least one thread.

B. All threads belonging to a process share all the resources of the thread, including open files and Socket. Different processes are independent of each other.

C. A thread is also called a lightweight process.

D. A process is the execution of a program. A thread can be understood as the execution of a program segment in the program.

E. Each process has an independent memory space, and the thread shares the memory space of the process to which it belongs.

2. What mechanisms does thread synchronization have?

Currently, the popular process thread synchronization mutex control mechanism is actually the most primitive and basic four methods: critical section, mutex, semaphore and event.

3. Differences between kernel threads and user threads

Based on whether the operating system kernel is aware of threads, threads can be divided into kernel threads and user threads.

Kernel thread creation and destruction are completed by the operating system and called by the system. During scheduling, the operating system determines the Scheduling Based on the running status of the threads in each process.

A user process is a thread implemented in a user program without kernel support. It does not depend on the core of the operating system, the user process uses the thread library to provide functions for creating, synchronizing, scheduling, and managing threads to control user threads.

Ii. Memory Management

1. Memory Management Methods

Common memory management methods include block management, Page Management, segment management, and segment-page management.

2. What is the difference between segmentation and paging?

Pages are the physical unit of information. pages are used to achieve discrete distribution, reduce the external zero header of memory, and improve the memory utilization. Or pages are only required by system management, rather than the user's needs.

Segment is the logical unit of information. It contains a set of relatively complete information. The purpose of segmentation is to better meet user needs.

The paging job address space is unique, that is, a single linear space, indicating an address. The segmented job address space is two-dimensional. When a programmer identifies an address, both the segment name and the intra-segment address are required.

3. What is virtual memory?

Virtual Memory (VM) is a technology used to manage the memory of computer systems. It is relative to a physical address and can be understood as "fake" memory.

It makes the application think that it has continuous available memory (a continuous and complete address space), allowing programmers to write and run programs that are much larger than the actual system memory, this allows many large software projects to be implemented on systems with limited memory resources. In fact, it is usually divided into multiple physical memory fragments, and some are temporarily stored in the external disk storage for data exchange as needed.

Compared with reality, virtual storage has the following benefits:

A. Expand the address space

B. Memory Protection

C. Fair Memory Allocation

D. When the process needs to communicate, it can be implemented through virtual storage sharing.

4. What is memory fragmentation? What is inner fragmentation? What is external fragmentation?

Memory fragments are caused by multiple memory allocations. When memory is allocated, the memory format is generally (user segment) (blank segment) (user segment ), when the blank segments are small and cannot be provided to users with enough space, these small gaps are called fragments.

Internal fragments: the storage space allocated to the program is useless. Some of them are not used by the program, but other programs cannot be used.

External fragments: because the space is too small, the storage space cannot be allocated to any program (not any process.

5. What are the differences between virtual addresses, logical addresses, linear addresses, and physical addresses?

Virtual Address: an address that consists of a segment selector generated by the program and an offset address in the segment.

Logical Address: the offset address in the segment generated by the program. Sometimes the logical address is regarded as a virtual address, and there is no clear boundary between the two.

Linear address: the intermediate layer between virtual addresses and physical address transformations. It is an address in the memory space (called linear address space) that the processor can address.

Physical address: refers to the address signal that addresses physical memory on the CPU external address bus and is the final result of address transformation.

6. What are Cache replacement algorithms?

Cache replacement algorithms include random algorithms, FIFO algorithms, Recently Least-Used algorithms (Least Recently Used, LRU algorithms), LFU algorithms (Recently Least-accessed algorithms), and OPT algorithms (Optimal Replacement algorithms)

3. User Programming Interface

1. What is the difference between library function calls and system calls?

Library Function calling is a part of the language or application. It is high-level and fully runs in the user space. It provides programmers with a system call interface that truly completes real transactions behind the scenes;

System functions are the interfaces provided by the kernel to applications and are part of the system. A function library call is a part of a language or application, while a part of the operating system is called by the system.

2. What is the difference between static and dynamic links?

Static links are used to directly link a function or process to an executable file and become part of the executable file. In other words, functions and procedures are stored in the program's exe file. This file contains all the code required for running. The disadvantage of static links is that when multiple programs call the same function, multiple copies of the function will appear in the memory, resulting in a waste of memory.

A Dynamic Link is relative to a static link. The function called by the dynamic link is not copied to the executable file of the application, instead, only the description of the called function is added. Only when an application is loaded into the memory and starts to run can a link be established between the application and the corresponding dynamic link library (dll) under the management of the operating system.

3. What is the difference between a static link library and a dynamic link library?

The static link library uses the. lib file. The code in the library must be linked to the executable file. Therefore, the static link executable file is generally larger.

A Dynamic Link Library is a library that contains code and data that can be used by multiple programs at the same time. It contains a set of modules for functions and data structures. These modules are loaded only when the program file is running.

Their similarities are that they all share code.

The difference is that the Code in the static Link Library lib is included in the called exe file, which cannot contain other dynamic or static link libraries. The dynamic link library dll can be called by the exe to dynamically "Reference" and "Uninstall". This dll can contain other dynamic or static link libraries.

4. What is the difference between the user State and the core State?

The user State and the core situation operating system run at two levels, which are used to distinguish different rights of different programs.

The core State is the State with many resources, or the State with many resources accessed, also known as the privileged state.

Access to resources in the user State is limited.

Intel CPU provides Ring0 ~ Four running Modes of Ring.

5. What is the difference between the user stack and the kernel stack?

Stack is the stack used when the system runs in the kernel state, and the user stack is the stack used when the system runs in the user State.

When a process enters the kernel state due to interruption, the system will save some user State data information to the kernel stack. When it returns to the user State, the information in the kernel stack will be retrieved and restored, return to the place where the program was originally executed.
A user stack is the stack created by a process in a user space. For example, a common function call will be used in a user stack.

The kernel stack is a fixed area of the operating system space. It can be used to save the interrupt scene, and to save parameters and return values that are mutually called between operating system subprograms.

The user stack is an area of the user's process space. You can save parameters and return values of mutual calls between user process subprograms.

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.