OS_Chapter_3.2

ssonjh·2021년 4월 7일
0

OS

목록 보기
16/17

👀 Process Scheduling

📕 objective of Process Scheduling

  1. The objective of multiprogramming is to have some
    process running at all times, to maximize CPU utilization.
  2. The objective of time sharing is to switch the CPU among processes so frequently that users can interact with each program while it is running.
  • To meet these objectives, the process scheduler selects an
    available process for program execution on the CPU

  • For a single-processor system, there will never be more
    than one running process.
    • The rest will have to wait until the CPU is free and can be rescheduled.

Summary

objective of Process Scheduling

  1. multiprogramming의 목적은 process를 항상 실행시켜, CPU사용률을 높이는 것이다.
  2. time sharing의 목적은 CPU를 process 간에 자주 전환하여 실행 중인 각 program과 상호 작용할 수 있도록 하는 것이다.
  • 이 목적을 달성하기 위해, Process Scheduler가 CPU에서 program 실행에 사용할 수 있는 process를 선택한다.
  • single-processor system에서는 process가 한 개 이상 실행될 수 없다. 만일 process가 여러개 있다면, 나머지 process들은 다시 Schedule 될 때까지 대기해야 합니다.

📙 Process Scheduling Queues

  • Processes migrate among the various queues for process scheduling

Ready queue

  • set of all processes residing in main memory, ready and waiting to execute
    • Generally stored as a linked list; each PCB includes a pointer field that points to the next PCB

wait queue

  • Processes that are waiting for a certain event to
    occur, ex. completion of I/O

Summary

  • Process들은 process scheduling에 따라 다양한 queue들 사이를 옮겨 다닌다.

Ready queue

  • main memory에 있는 모든 process 세트들은 Ready queue에서 실행 준비 및 대기 상태에 있다.
    • 일반적으로 linked list로 되어 있다. 각 PCB의 header는 다음 PCB, tail은 마지막 PCB에 대한 pointer field 정보를 포함하고 있다.

Wait queue

  • 특정 event가 발생하기를 기다리는 process가 들어가 있는 곳이다.
    ex) I/O 완료

📒 Sequence

  1. A new process is initially put in the ready queue and waits there until it is selected for execution.

  2. Once the process is allocated the CPU, then it is executing until one of the following events occur:
    • The process issues an I/O request
    • The process creates a new child process
    • The process waits for an interrupt (timer event)
    • The time slice assigned is expired.

Summary

  1. 새로운 process는 처음에 ready queue에 넣어지고, 실행을 위해 선택될 때까지 대기하고 있다.
  2. process가 CPU에 할당되면, 다음 이벤트 중 하나가 발생할 때까지 실행된다.
    • I/O에 대한 요청이 발생했을 때
    • process가 하위 process를 생성했을 때
    • process가 interrupt를 기다릴 때 (time event)
    • 할당된 시간이 만료되었을 때

📗 Context Switch

  • When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch
  • Context of a process represented in the PCB
  • Context-switch time is overhead; the system does no useful work while switching

    • The more complex the OS and the PCB -> the longer the context switch
  • Time dependent on hardware support

Summary

  • CPU가 다른 process로 바꿀 때, system은 반드시 이전 process의 상태를 저장해 놓아야 하고, 새로운 process에 대한 저장되어 있던 상태를 context switch를 통해 load한다.
  • process의 context(문맥)PCB 안에 있다.
  • Context-switch에 걸리는 시간은 overhead(간접 시간)이다.
    process가 바뀌는 시간에는 system이 유용한 일을 하기 힘들다.
    • OS와 PCB이 복잡할수록 Context-switch에 걸리는 시간은 늘어난다.
  • 시간은 hardware의 지원에 영향을 미친다.

process가 바뀔때 상태를 저장하고, 나중에 다른 process로 바뀌면서 그 상태를 불러오는 것을 문맥(context)이 바뀐다고 표현하는 듯 하다..


📘 Multitasking in Mobile Systems

옛날에는 mobile에서도 single process를 사용하였지만, 지금은 multitasking을 한다.

ios

• Single foreground process : controlled via user interface
• Multiple background processes : in memory, running, but not on the display, and with limits

Android

• runs foreground and background, with fewer limits
• Background process uses a service to perform tasks


dictionary
migrate 이동
dispatched 할당되다
suspend 매달다

0개의 댓글