Processes and Process Management

이두현·2021년 12월 27일
0
post-custom-banner

PCB (Process Control Block)

  • Datastructure that OS maintains for every process to remeber its information

  • created with a process

  • register and program counter is changed at every instruction

  • CPU deals with the above information but it's OS' job to collect and save information whenever the process is not on the CPU

Overall flow of PCB and CPU register with two processes


check cpu holds value of currently operating process

Context switch

  • change CPU context of one process to the other
  • two types of cost
    1. Direct cost: # of cycles for load and store ops itself
    2. Indirect cost: cold cache problem (whenever the process change it will experience cache misses at the beginning due to the hierarchical form of modern cache structure)

State illustration of the process

Tree like process

example of the process structure

  • top three are the initial processes created after the boot process
  • when user logs in, user shell process is created (csh in the figure)
  • two types of child process creation mechanism
    1. Fork: makes duplicate of the current process including code, PCB -> parent and child will be executing the same code (new PID is assigned)
    2. Exec: Replace current process with the entirely new process -> load and process from the beginning

CPU scheduler

Three types of functions

  1. Preempt: interrupt and save the current context
  2. Schedule: choose which process to start next
  3. Dispatch: dispatch process and switch CPU into its context

Interaction btw process

Message passing IPC

  • OS provides communication channle with a shared buffer

Shared memory IPC

  • OS does not manage the communicatino btw process
  • Use shared kernel memory region to communicate each other
  • Pro: No overhead for OS for process to communicate
  • Con: No typcial API could cause error when communicating

pros and cons of message passing IPC and Shared memory IPC are vice versa

profile
0100101
post-custom-banner

0개의 댓글