• 沒有找到結果。

Operating Systems Concept

N/A
N/A
Protected

Academic year: 2022

Share "Operating Systems Concept"

Copied!
5
0
0

加載中.... (立即查看全文)

全文

(1)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Operating Systems Concept

?What is an operating system?

?Operating system architecture

?Process concept

?CPU scheduling

?Memory management

?File and I/O systems

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

?Process

?An active entity

?The corresponding passive entity

?Program code

new

ready

running waiting

zombie

fork

scheduled

interrupt exit

I/O or event waiting completed

stop

suspend resume

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 89-97, p 126.

(2)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

?Process Image in Memory

?System Resources

? Program Counter (PC)

? Process Status Register

? Stack Pointers (sp)

? Memory

? etc.

Code Segment Data Segment

PC heap

user stack argv, argc,…

sp

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

?Process Control Block Struct PCB {

char p_pid;

char p_pri;

char p_ppid;

int pc; /* program counter */

int rq_former, rq_next; /* for ready queue*/

int files[NFILE];

} PCB[NPROC];

• major queues:

• I/O queues

• ready queue

(3)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

Process i OS Process j

Save state into PCB[i]

..

Load state from PCB[j]

Save state into PCB[i]

Load state from PCB[j]

.. .. ..

Interrupt or system call

Interrupt or system call

dispatch

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Scheduling

?A Ready Queue

Priority -decreasing

0 1 2

PCBi PCBj

PCBk

• Select the highest-priority process to run and de-queue it!

• Hook the running process

back to the ready queue!

(4)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Context Switching – Necessary Overheads for Multiprogramming

?Def.

?Switch the CPU from one process to another process

?Save the state (or called context) of the running process

?Reload the state of the ready process

?Context Switching Time

?Hardware-dependent!

?Multiple register sets!

?Special hardware instructions!

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

?Kernel-Supported Thread

?A program counter

?A register set

?A stack space

?User-Level Thread

Code Segment Data Segment

user stack sp1

PC1 user stack sp2

PC2

* “Operating system concept”, Silberschatz and Galvin, Addison Wesley, pp. 103

OS

A process with one

kernel-supported thread

(5)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.

Process Concept

?Thread – Lightweight process

?An ordinary process contains one thread!

?Types

?Kernel-Supported Threads

?User-Level Threads

OS OS OS

Ordinary process 3-kernel-supported threads in a Process

3-user-level

threads in a Process

參考文獻

相關文件

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.. Operating

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005!.

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.. Operating

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.. Operating

* All rights reserved, Tei-Wei Kuo, National Taiwan University,

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.. Operating

* All rights reserved, Tei-Wei Kuo, National Taiwan University,

* All rights reserved, Tei-Wei Kuo, National Taiwan University,