운영체제 인터뷰 준비용
Introduction
What is an operating system
Intermediary between a user and the hardware.
How does multiprogramming work?
Several processes are stored in memory at one time, when one process is done and is waiting, the os takes the CPU away from that process and gives it to another process.
How does the operating system run a program, What does it need to do?
1) reserve machine time
2) manually load urge program into memory
3) load starting address and begin execution
4) monitor and control execution of program from console
Type of Queues:
- Job Queue: data structure maintained by the job scheduler containing jobs to run
- Ready Queue: processes that are ready and waiting to execute (loaded on to the memory)
- Device Queue: processes that are waiting for I/O device (each device has its own queue)
Long-term scheduler brings a job from job queue(secondary storage) into ready queue(memory). If process needs to wait for I/O operation, process is then moved to device queue.
Type of Schedulers:
- Long-term Scheduler: selects which process should be brought into the ready queue
- Short-term Scheduler: selects which process should be executed next and then allocates CPU
Shared Memory
A region of memory that is shared by cooperating process. Processes can exchange information by reading and writing to the shared region (faster than message passing)
CPU scheduling / scheduler
to maximize CPU utilization. Picks a process in the ready queue to be executed if the CPU becomes idle.
Dispatcher
Modules that gives control of the CPU to the process selected by the CPU scheduler. this involves context switch
CPU scheduling criteria
- CPU utilization
- Throughput
- Turnaround Time : total time taken from request to response
- Waiting Time
- Response Time
CPU scheduling algorithms
- First-Come, First-Served: Convoy Effect(Entire processes having long wait time due to one long process)
- Short-job-First
- Round-Robin : Each process is given fixed time quantum
- Priority Scheduling: Process with higher priority gets processed first(based on CPU burst)
- Job Queue: data structure maintained by the job scheduler containing jobs to run
- Ready Queue: processes that are ready and waiting to execute (loaded on to the memory)
- Device Queue: processes that are waiting for I/O device (each device has its own queue)
Long-term scheduler brings a job from job queue(secondary storage) into ready queue(memory). If process needs to wait for I/O operation, process is then moved to device queue.
Type of Schedulers:
- Long-term Scheduler: selects which process should be brought into the ready queue
- Short-term Scheduler: selects which process should be executed next and then allocates CPU
What is context switch?
Process of storing the state of a process/thread, so that it can be restored and resumed from the same point later. Context switch stores program counter, stack pointer, etc in PCB(Process Control Block)
Context switching cost:
- cache reset
- memory mapping reset
- requires kernel to be running (to access memory)
Process costs more than thread because thread shares every memory except Stack.
Memory Structure:
- Code: Hex or Bin code
- Data : Global and static variables (프로그램 시작과 동시에 할당되고 종료되면 소멸)
- Stack: Argument and local variables
- Heap: Used for dynamic allocation during runtime (by programmer)
Purpose of Kernel:
- Memory management (kernel has full access to memory and must allow processes to access it using Virtual memory)
- Resource management (scheduling / context switching)
- Hardware(low-level) abstraction (Application requests to Kernel. Kernel forwards it to device driver)
System Call
Process sending request to Kernel to send request to the OS
Process of storing the state of a process/thread, so that it can be restored and resumed from the same point later. Context switch stores program counter, stack pointer, etc in PCB(Process Control Block)
Context switching cost:
- cache reset
- memory mapping reset
- requires kernel to be running (to access memory)
Process costs more than thread because thread shares every memory except Stack.
Memory Structure:
- Code: Hex or Bin code
- Data : Global and static variables (프로그램 시작과 동시에 할당되고 종료되면 소멸)
- Stack: Argument and local variables
- Heap: Used for dynamic allocation during runtime (by programmer)
Purpose of Kernel:
- Memory management (kernel has full access to memory and must allow processes to access it using Virtual memory)
- Resource management (scheduling / context switching)
- Hardware(low-level) abstraction (Application requests to Kernel. Kernel forwards it to device driver)
System Call
Process sending request to Kernel to send request to the OS
Shared Memory
A region of memory that is shared by cooperating process. Processes can exchange information by reading and writing to the shared region (faster than message passing)
CPU scheduling / scheduler
to maximize CPU utilization. Picks a process in the ready queue to be executed if the CPU becomes idle.
Why are queues and schedulers important?
They determine which program is loaded into memory after one program finishes processes and when the space is available
Dispatcher
Modules that gives control of the CPU to the process selected by the CPU scheduler. this involves context switch
CPU scheduling criteria
- CPU utilization
- Throughput
- Turnaround Time : total time taken from request to response
- Waiting Time
- Response Time
CPU scheduling algorithms
- First-Come, First-Served: Convoy Effect(Entire processes having long wait time due to one long process)
- Short-job-First
- Round-Robin : Each process is given fixed time quantum
- Priority Scheduling: Process with higher priority gets processed first(based on CPU burst)
Process
What is a process?
A process is a program in execution
Process
Each process provides the resources needed to execute a program. A process has a virtual address space, executable code, open handles to system objects, a security context, a unique process identifier, environment variables, a priority class, minimum and maximum working set sizes, and at least one thread of execution. Each process is started with a single thread, often called the primary thread, but can create additional threads from any of its threads.
Each process provides the resources needed to execute a program. A process has a virtual address space, executable code, open handles to system objects, a security context, a unique process identifier, environment variables, a priority class, minimum and maximum working set sizes, and at least one thread of execution. Each process is started with a single thread, often called the primary thread, but can create additional threads from any of its threads.
What does a process need?
- CPU time
- memory
- files
- I/O devices
Why is Process Control block created?
So that the OS knows information on the process
What are the process states?
- New: process is being created
- Ready: process is waiting to be assigned to a processor
- Running: instructions are being executed
- Waiting: The process is waiting for some event to occur
- Terminated
What does a process include?
- Program Counter
- Stack: contains temporary data
- Data section: Global variables
Thread
What is a thread?
A basic unit of CPU utilization, consisting of a program counter, a stack, and a set of registers.
Thread
A thread is an entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources. In addition, each thread maintains exception handlers, a scheduling priority, thread local storage, a unique thread identifier, and a set of structures the system will use to save the thread context until it is scheduled. The thread context includes the thread's set of machine registers, the kernel stack, a thread environment block, and a user stack in the address space of the thread's process. Threads can also have their own security context, which can be used for impersonating clients.
- Responsiveness: can be responsive even when some threads are busy
- Resource Sharing: threads share common code / data / etc which allows multiple tasks to be performed simultaneously in a single address space
- Scalability: A single threaded process can only run on one CPU, whereas multi-threaded application may be split amongst available processors
Difficulties of multi-threading?
- Debugging
- Data Splitting: race conditions
- Dividing Tasks
- Data Dependency: If one task is dependent upon the result of another, tasks need to be synchronized to assure access in the proper order
댓글
댓글 쓰기