Vous êtes sur la page 1sur 256

Alpha

Version

...

1429/1428
.

) (Alpha
.

:
:
:
:
:
:
:
:
:
:
:
: .

.
:

1

)1940(
.




) IOCS: Input/Output Control
(System
.
.

1 :*)( &!"#"$%



.

.


)(General Motors Research Laboratories
IBM 701 Mainframe 1956
. ).(Batch Computing

: Multiprogramming


.
) . (JCL: Job Control Language
.

)( ) 1960(
.




.
) .(Multiprogramming

!.
.

) (Timesharing


.


)1970( .

). (TCP/IP

) (


.

) (UNIX
Assembly
( (Language
C .

.
).(Bell Laboratories

.
.

) Steve Jobs Steve Wozniak 1975(


.
.

.
.
.

IBM
.
. )
(
IBM .
( (Intels 16-bit 8080

. Bill Gates .
Bill Gates 10
50 !.
Bill Gates IBM
Tim Paterson 8080 QDOS:
( (Quick and Dirty Operating System Microsoft
. ( (MS-DOS
1991 1700
.

:
http://www.computinghistorymuseum.org/teaching/papers/research
/history_of_operating_system_Moumina.pdf
:


Operating System Structures

,
,
.

.
, .

)(xxdewdropsxx@gmail.com
:
: (Operating System Services)2

: :

-1 ):(User Interface

,
:

( Command Line Interface-CLI).1 .

( Graphical User Interface-GUI).2


.

-2 ):( Program Execution

,
- .-

-3 ) :(I/O Operations

2()S : &(OPQ ,M(X &WU ,M ["X&W")Z



.

-4 ):(File System Manipulation

.
,
, .

-5 ):(communications


. .
: ) ( shared memory
). (message passing

-6 ):(Error Detection

!

.

:
):(resource sharing

-1 ): (Resource allocation

, :
.

-2 ): (Accounting

-3 ): (Protection and security

Operating system Concepts (Seventh Edition): Abraham Silberschatz,Peter Baer


Galvin,Greg Gagne
http://www.personal.kent.edu/~rmuhamma/OpSystems/Myos/sysService.htm
: (User Operating System Interface)3

. ) (shell
.
.
,
.
Bourne,Bash Korn C Bourne
.Again

.

:
 .
 ) .(kernel
 .
 . .

, :

: ):(Command Line Interface-CLI



. .

3 : Uh(i&cZ UO(f &cdUOm Mn&)  $&U !X&o"(X%


, command line interpreter
.

MS-DOS command line interface .

: ) :( Graphical User Interface- GUI

-
.
, .
) (.

) :(ZUI - zoomable user interface

, ,
,
, .
iPhone ,Google Maps , Google Earth :

:
Operating system Concepts (Seventh Edition): Abraham Silberschatz,Peter Baer
Galvin,Greg Gagne
http://ar.wikipedia.org/wiki
http://en.wikipedia.org/wiki
http://www.opendirectorysite.info


http://en.wikipedia.org/wiki/ZUI
4
: )( System Calls

.
) ( .

,

.

, ,

) .(parameters :
.1 ) .(register

.

.2 , stack
. .

.3 ) (block ),(table
) (register
.
,

4 s)S :&U$ v [u UOm M*U&) $&U !X& o"(X% s#&("O c &("f%M
, stack
!

.1 : / / /
.2 : / /
.3 : /

.4 : / /
.5 .

): application program interface(API

) ,(API's ) system

) (kernel mode . (call
)( -open :
) . (open () >>>>>open system call
!
.
:
:
Win32 API .1
POSIX API .2 UNIX Linux Mac OS X
JAVA API .3 .

,
:
.1 ) (Portability .
:
WindowsLinux Mac .
, .2
.
)system calls
:(implementation of

) (API ) (index ,
) , (system table ). (index
):(index

)( , -open
, ,
) (system table :

Operating system Concepts (Seventh Edition): Abraham Silberschatz,Peter Baer


Galvin,Greg Gagne
http://en.wikipedia.org/wiki/System_call
http://data.uta.edu/~ramesh/cse3320
http://tiger.la.asu.edu/Quick_Ref/Linux_Syscall_quickref.pdf
http://www.slideshare.net/guestd1b5cb/adding-a-system-call
: (System Programs)5


,
.

: , , ,
.
: , , ,
.
: .
: .
: .
:
.

Operating system Concepts (Seventh Edition): Abraham Silberschatz,Peter Baer


Galvin,Greg Gagne

5 : oS&|{"$
6
: )(Operating Systems Structure

:
.1 ): (Monolithic
.

: .
:
.
.
.
.

.2 ): (Layered
)(
(layer 0) 0 ) (Hardware ) (layer N
, :

6 : ["X&W")Z
: .
: .

.3 ) : (Microkernel
.

).(message passing
:
)( .
.
:
.

.4 ): (Modules-based

.
:
Operating system Concepts (Seventh Edition): Abraham
Silberschatz, Peter Baer Galvin, Greg Gagne
: )(Virtual Machines7


.
.
.


.
 .
 .

 .

.
 ,
.

) ,(JAVA Virtual Machine


.
7 :" [X~ ,MXc &("f% ,Mc &&(Z
:

1421/3/29 122 http://www.fantookh.com/


www.cis.nctu.edu.tw
http://tarksiala.blogspot.com/2007/06/vmware-60.html
8
: )(Operating system generation

,

. ,
) (SYSTEM GENERATION " ".

) ,(CD
" "SYSGEN
,
, :
, .
.
, .
, , .

,
,
.

:
Operating system Concepts (Seventh Edition): Abraham
Silberschatz, Peter Baer Galvin, Greg Gagne

8 : ["X(cO
:


Processes

.
.

.
process .
time-sharing.

.
: ) (code
.
) (CPU .multiplexed
.

:
Operating System Concepts: Silbreschatz, Galvin and Gagne, 7th
edition
wiki :
http://os1h.pbwiki.com/
http://os2h.pbwiki.com/
http://os3h.pbwiki.com/
http://os2a.pbwiki.com/

)(Hend.khalid@gmail.com
:
: Process Concept9

:
) ,(CPU .
.
) (operating systems

. .

.

10
Process
) ( :
o ) (address space )
(
o ).(program code
o ).(program data
o ).(stack pointer
o )) (program counter
(.
o ) (register.
o ) (heap .

9 s#&("O
&|Xhttp://en.wikipedia.org/wiki/Process_%28computing%29 :
10 &($d
: Processes State11

,
.

:
)) (new (:

RAM
": ".

):(ready
CPU
.

):(Running
. CPU

):(waiting
:
.

):(terminated

("X& 11 &(uU
&Operating System Concepts: Silbreschatz, Galvin and Gagne, 7th edition :nUX
,
.

- )( :
.
- )( : )(CPU
) (CPU
) ( .
- )( : )(
.

12

!S 12cQ &("X &(uU



)( ) (CPU

:
o ) (terminated

o ) (ready

o ) (waiting

o
.

Process Control Block13

) (Process Control Block


PCB
, , :

o ) :(state , , ,
.

13) &U"OX
&Operating System Concepts: Silbreschatz, Galvin and Gagne, 7th edition :nUX
http://en.wikipedia.org/wiki/Process_control_block
o ) :(Program Counter
.

o ) :(Registers
, )( (stack
) ,pointer ) (index registers
) (general-purpose registers
) (condition-code information
, .

o ):(CPU-scheduling information
, .

o ) :(memory-management information
) (base ) ,(limit
) (segment table ) (page table
.

o ) :(Accounting information
.

o ) :(I/O state information


, .

o PCB .
,
.
) (PCB ,
) (PCB .

14

):(PCB

.
) (kernel stack
.

15
: Process Scheduling

www.ice.ntnu.edu.tw/~swanky/os/chap4.htm 14

15c & !%"PX&UXOperating System Concepts: Silbreschatz, Galvin and Gagne, 7th edition :n

http://en.wikipedia.org/wiki/Scheduling

)(queue

:Scheduling Queues

.1 ) :(job queue

.2 ) :(ready queue
16
.3 ) :(device queue .


) (

http://en.wikipedia.org/wiki/Scheduling_%28computing%29

http://en.wikipedia.org/wiki/Ready_queue

(* 16W &U"OX
&Operating System Concepts: Silbreschatz, Galvin and Gagne, 7th edition :nUX
17
)(Scheduler

:queue scheduling

) ( job queue
)( ready queue


)(I/O queue

17
http://arstechnica.com/articles/paedia/cpu/hyperthreading.ars/4
18

:scheduler

:long-term scheduler


) real
(time system .

:medium term scheduler

) (virtual memory

) (secondary storage .

.

:short-term scheduler
18
www.cs.wayne.edu/~tom/guide/os.html
.


.

:19Types Of Processes

.1 )(CPU bound process

) (CPU
).(CPU burst

.2 )( I/O bound process

) (I/O
).(I/O burst



) (ready queue
.
20
.

S 19
M&M$"d
&Operating System Concepts: Silbreschatz, Galvin and Gagne, 7th edition :nUX
20UQ :($ & (S) ["Xd~c * M(O  & S [u&(dX
* &  M)d c s (#h US( U M&(&($*
())~X cQ (c ( U "|(* {$ ( (S(X&~! &! c(& o~i&cOX.
21
)(context switching
: ) (thread .
) (CPU scheduler .

) (context PCB
) (CPU registers .

:
.1
.
) (interrupt
.2 ) (context .
.3 )
) (interrupt .

22
:
.1 )(privileged mode
.2 ) (register
.3 ) (register
.4 )(user mode

21
(X &M&$
&http://www.linfo.org/context_switch.html :nUX
22 vX&(
&http://www2.cs.uregina.ca/~hamilton/courses/330/notes/processes/processes.html :nUX
23

Operations on Processes

Process Creations24

)System Call
( )( Parent Process
) (Child Process
.

http://www.ice.ntnu.edu.tw/~swanky/os/chap4/CPU_Switch_From_Process_to_Process.png 23

()S 24 &(OPQM
&Operating System Concepts: Silbreschatz, Galvin and Gagne, 7th edition :nUX
)(

.

)( - -


) (Process Identifier .

Ps command

) (function )( fork

.
) (PID 0

)( exec

25


.
26
Process Termination

:
.1 ) :( Normal Exist .
.2 ) :( Error Exist ) Fatal
.(Error ) (compile .
.3 ) :(Fatal Error :
.
.4 ) (kill .

Interprocess communication (IPC)27

http://www.freebsd.org/doc/en_US.ISO8859-1/books/design-44bsd/book.html 25
" 26&(fW
&http://www.personal.kent.edu/~rmuhamma/OpSystems/Myos/processOperate.htm:nUX
27
*( [X&Uf , (u& , &U"
Operating System Concepts: Silbreschatz, Galvin &and Gagne, 7th edition :nUX
):(Independent
.

):(Cooperating

:IPC

.1 ):(Message passing

)(Kernel

.

.2 ):(Shared memory
.

:


.

.
.
.
.

:Shared-Memory Systems
) ,
28
(.

:
):(unbounded-buffer

):(bounded-buffer

29
: )(massage- passing

)(/)(:

.1 .

28(# &M$"d
&UXwww.comms.scitech.susx.ac.uk/fft/computer/ipc.pdf :n
www.1006.org/os2006/labtext07_en.doc
http://www.alhasebat.com/vb/showthread.php?t=1878
http://www.cs.unc.edu/~dewan/242/f97/notes/ipc/node9.html
deneb.cs.kent.edu/~mikhail/classes/os.s00/L05ipcs.PDF

29(# &M$"d
&UXwww.comms.scitech.susx.ac.uk/fft/computer/ipc.pdf :n
www.1006.org/os2006/labtext07_en.doc
http://www.alhasebat.com/vb/showthread.php?t=1878
http://www.cs.unc.edu/~dewan/242/f97/notes/ipc/node9.html
deneb.cs.kent.edu/~mikhail/classes/os.s00/L05ipcs.PDF
.2 .

.3 )(buffer

.1 :

:
) ( buffer
.
:
)send ( receiver_process, message
)( send() :
receiver_process :
message :

:system call
)receive (sender_process, message
)( receive :
sender_process :
message :

: ,
) (mailbox . :
(mailbox, message) Send
)receive (mailbox, message

).(queue

:
.1 )(unique identification
.2
.3

):communication link (CL


.1
.2
.3 ,
.4

.2 :

.1 ):(blocking

,
.

.2 ):(unblocking
) (unblocking
, ) ( parallelism
.

.3 :buffering

.
: zero ) (queue

)(rendezvous

: ) (queue . n
, .
) (block send
.

: ,
.

/ .

30

[X(* 30&Uf , (u& , &U"


Operating System Concepts: Silbreschatz, Galvin &and Gagne, 7th edition :nUX
:

)(
Threads
:

) ( ,
,
.
) ( .

,
,
.
,


.

-1 .
-2 ) (.
-3 .
-4 .
-5 .
-6 ,
-7 .
-8 .
-9 .
.thread pool -10
.LWP -11
-12)( .

) (f.a.t.o.m.y@windowslive.com
) (yasamenah@hotmail.com .
: 31

31 UOm &) &o"(X%


:(Process) 32

) (application ,
:

-1 ) ( an executing program
, .
(Process) -2
)(mapping .
-3

:(Thread)33


) ( ) (
.
)(thread .

s)S32&U$v
("X&33 &%(
) address
. (space

thread !!
......

, ,
,
.

-1 ) (ID
-2) (program counter
-3)(register
-4)(stack

-1
, .
- 2 ) (
.
-3 .
-4 ) (SHARE CPU ) creat
.(child

34

-1
runtime -2 ) (address space )
(enivorment ) (process ID
, .
-3
-4 ) ( context switch , over head

.
-5 thread is a concurrent unit of ) .
(process execution inside a
-6 , " ".

s)S 34&U$ v "( &"c


-7 ) (
.
-8 .

.

:
) (register )(stack

) ) (code) (data
). (files

) (register )( . ( stack

) )(processes:35

) (1 ) ( single Threaded
)(2 )(multi Threaded

) ( multi Threaded
)(multitasking
)(time slicing


) (multiprocessor thread ).(scheduler

36
) ( multi Threaded):(single Threaded

35 & (X &M&$


UOm36&) &o"(X%
) (single Thread ) ( web server
) multi
( Threaded .

) ) (single threaded ) , (CPU


) ( multi Threaded ) , (multi-CPU
)(multi thread )( . (multi process

):37( multi Threaded

) (1 ): ( responsiveness

) (2 ) :( resourse sharing





37c &M$"d

, ) ( threads
) address
. ( space

) (3 ) : ( economy



.



.

)(4 :

.
- :
-1 :
.
-2 :
.

:38

POSIX Pthread -1

WIN32 -2
.
Java. Pthread - 3
.

:39

(User threads) -1 :

) (Kernel
) (library function
).(hard ware
) (Kernel

(Kernel threads) -2 :

38 oS&(XP
[X(*39&Uf
) (Kernel )(function
)(system call

:
Windows XP/2000, Solaris, Linux, Mac OS X -
- ) (Kernel

) )(thread :40

- ) : (user_space thread .
- ) : (kernal )(kernal

) (user_space thread
) ( kernel .

):41(multi Threading Models

) (1 : Many-to-one Mode

) user
(threads ), (kernel threads
)( thread
) , (library

.

s)S40&n(X
(41 &(UQ
: )( kernel

:
.Solaris Green Threads, GNU Pthreads

) One-to-one Mode(2

) (user threads
) (kernel threads ,

,
) (user threads
) ( kernel ,
.

:
) ( kernel ) (user thread
) (kernel ) .(Kernel
. Linux, windows 95,98,NT,2000,XP :
Many-to- )(3
: many Model

) user
(threads
)(kernel threads

) ( user threads
) .(kernel

) (4 )(Two-level Model
) (Similar to M:M M:M

IRIX,HP-:
(. UNIX UX and Tru64

) ( M: M) (Two-level-model ,
kernel thread ,
LWP kernel
kernel thread . user thread

42

User Level Threads vs. Kernel Level Threads

Kernel level thread User level thread

User level
thread




thread
) (Kernel
thread .
) single
(threaded user thread

other
threads
.

42)( " &)#


:43

)(fork() and exec

,


,
.

) (Cancellation:



,
,
""
,

.

43)( " &)#


:44

: ( Asynchronous cancellation )-1


.
:( Deferred cancellation )-2

.

:
>#include <pthread.h
;)int pthread_cancel(pthread_t thread

:45

CTRL-C ( for foreground processes ) -1


-

Kill process-identifier ( for Background processes )-2


Process-identifier
ps

process-identifier


Kill -1 process-identifier

44(X &M&$
45c &()PM

child

Kill -9 process-identifier
child


Kill process-identifier process-identifier

)) (Signal handling :46


, .

) :( .
) : ( .

:(default) -1 .
:(user-defined)-2 .

:Synchronous Signals

46 &)d
, , ,
Synchronous
.Signals

:Asynchronous Signals

, ) ( .
, Control + c .

-1 .
-2 .
-3 .
-4 .

, Synchronous Signals
.
thread
.
Asynchronous Signal .
thread .
, APCs (Asynchronous
).procedure calls
user thread ) (function
. .
:47

ctrl+z ctrl+c
.
ctrl+z kill
pash pash kill kill :
( . (kill 9)<-- pash

:Thread pool

) (pool
.
:
-1 ). (cpu time
- 2 .

) (pool )(pool
)(pool ,
) (pool .

): (pool

-1 .
-2 ) (POOL ..
.

s)S47~ , MX" vX~ UOm MX&) &o"(X%


:

) (CPUs ,
.
) (pool
.

)(thread library
.

.
Lightweight process LWP
.
LWP .

LWP .

,
LWP.
:48Scheduler Activation

User thread library

LWP
.
:Upcall .

Upcall handler
.
:Upcall
, .

48 &)d
:context switch and multi-threading49

multi-threading TCB , Context switch


TCB
. TCB

:
: .
: .

) (threads :50

-1 : .
-2 : .
: word process

save every two min & spell check in one
.process
-3) (process ) (server .
-4 ) (data ) interprocess
.(communication
-5 . processes
-6 kernal thread
.

s)S49&n(X
50 & , (X & M&$*)( &U"P$
:51

-1 .
-2 ) (stack ) (register .
-3
) (address space
) (data global ).(program code
-4 ( pc
program counter ) , sp (stack pointer) , register.

51(X &M&$
:


CPU Scheduling

) (CPU
) (processes ) (CPU )(process

!
) (CPU scheduler

.


 ) (CPU scheduling
)(multiprogramming




) CPU-I/O
(Burst Cycle
)(CPU Scheduler
)(Preemptive Scheduling
dispatcher

 )(Scheduling Criteria

 )(Scheduling Algorithms
))(First-come First-served (FCFS-FIFO
))(Shortest-Job-First (SJR
) )( Round Robin (RR
)(Multilevel Queue
)(Multilevel Feedback Queue

 )(Multiple-Processor Scheduling

 ) ( Thread Scheduling

) (k.alroumi@gmail.com

))
((
)(CPU Scheduling Mind Map
) CPU-I/O
:(Burst Cycle

) (Process
) (CPU .

) (CPU burst
) (I/O burst
) (CPU burst
) (I/O burst
) (CPU burst ) (OS
.

) (I/O bound
) (CPU burst
) (I/O burst
) (CPU bound .

)(CPU bound
) (CPU burst
) (CPU burst
) (I/O bound
) (CPU burst ) (CPU burst.
) (CPU burst
) (CPU burst
) (frequency .

-1 (I/O bound
): processes
,
) (CPU CPU bursts

-2 (CPU bound
):processes
) (CPU
CPU bursts
:

-1 ):(interactive processes

) (input )(wake up
) (avg delay 50-150ms
.
.

-2 ):(batch processes

.
) (batch processes
.

-3 ):(real-time processes

.

v"X&W")Z - & - [S%) &U"OX s)S&n(X


@?><;:
Operating System Concepts
)(CPU Scheduler

) (CPU ) ( idle
). (ready queue
) (short-term scheduler
) (ready queue
) (CPU.

:
-1 ):(long-term scheduler
) (processes


.

-2 ): (short-term scheduler
) (process ) CPU
(.



.

-3 ):(medium-term scheduler


.

.

c & !%"PXc &(X ( &Ui


@?><;:
Operating System Concepts
http://en.wikipedia.org/wiki/Scheduling
http://en.wikipedia.org/wiki/Scheduling_%28computing%29
http://en.wikipedia.org/wiki/Ready_queue
): (Preemptive Scheduling

) :( preemptive scheduling

.

) : ( non-preemptive scheduling
.

-1 ) (Process ) :
/ , ).( (child
-2 ) (running state ) ready
) (state: ) (time out (.
-3 ) :(.
-4 ).(Terminate

1 4 )non-
(preemptive ).(preemptive

) (non-preemptive )(CPU
) (CPU
.
) (non-preemptive
, ) : ( Timer ) (Kernel
) ( DOS
) (preemptive ) (Kernel
) (CPU .
) (Multiprocessing
.

) &U"OX *(W &UXi


@?><;:
Operating System Concepts

dispatcher

dispatcher " " "" ,


dispatcher ) ,(CPU-scheduling
) (module )short -
. (term scheduler

, ) CPU
, (scheduler ) ,(dispatcher
) (CPU scheduler
) (ready queue ) (CPU
.
) , (Dispatcher ,
- - ) (CPU.


-1 ).( context switch
-2 .
-3 .
)(dispatcher latency

:

["X(cO UOm&) & o"(X%" [X~MX


@?><;:
Operating System Concepts
): (Scheduling Criteria


) (CPU
:

-1 )(CPU utilization
) (CPU

:
- = ) ( ) /
( * 100
- = ) () / +
(* 100

!

.

-2 )(Throughput

-3 )(Turnaround time

-
- )(ready queue
-
-

-4 )(Waiting time
) (ready queue
)(CPU

-5 )(Response time

(interactive) system .

( maximum CPU
) utilization ) (
Throughput
) (Waiting time
) (Response time )(Turnaround time


) ( CPU utilization (context
)Switching ) (
) (CPU
) ( Response time
). (Ready Queue

) (Average turnaround time



) (maximum waiting time
.

). (average waiting time

*( [X&Uf *(W &UXi c &&(Z (f &cd Mnc &UMS


@?><;:
Operating System Concepts
: Scheduling Algorithms

): First-come First-served (FCFS-FIFO


) (CPU ) (Non-preemptive

) (kernel .

.1 .
.2 .
.3 ) (performance
)(convoy effect
.
.4 ) (interactive system
(non
)preemptive scheduling

:1
:2

) (Burst time )(Process


P1 24
P2 3
P3 3

t0 P1,P2,P3

Gantt chart:
0-23 24-26 27-30
P1 P2 P3

)17 =3/(27+24+0) = (Average waiting time

: P2,P3,P1
0-2 3-5 6-30
P2 P3 P1

)3 =3/(6+3+0) = (Average waiting time

): Shortest-Job-First (SJR

.1 ) : (Non-preemptive

.

.2 ) :(Preemptive



.



.
:
) t( n+1 ) = w * t( n ) + (1 - w ) * T( n
:
) t(n+1
) t(n
) T(n
W 0 <= w <= 10


) ( .

: )
(starvation :
.

.1 .
.2 .

:1
:( (Non-preemptive) ) 2

(Process) ( Burst time)


P1 6
P2 8
P3 7
P4 3
Gantt chart:
0-2 3-8 9-15 16-24
P4 P1 P3 P2

7 =4/(16+9+3+0) = (Average waiting time)

:( (preemptive) ) 3

(Arrival (Burst
(Process) time) time)
P1 0 8
P2 1 4
P3 2 9
P4 3 5
Gantt chart:
0 1-4 5-9 10-16 17-25
P1 P2 P4 P1 P3

-17)+(1-1)+(1-10)) = (Average waiting time)


6.5 = 4 / ((3-5)+(2

: Round Robin (RR)



) (CPU ).(time quantum
 ) (time quantum 100 -10 milliseconds
.
 (time
) quantum q \1
 ) - 1 ( * .
 ) (FCFS
). (CPU


 ) (time quantum
)(FCFS
 ) (time quantum
)(context switch

:1
:
):(Multilevel Queue

) (ready queue )(queues


, :




) (queue .



) (queue



) (queue ) ) (ready queues
( multilevel feedback

)
( :

.1 :



.

.2 ) : (time slice ) 5(

.
):(Multilevel Feedback Queue

) (multilevel queue
) (ready queue .
) (FIFO queues
) (
.

:
) (queue
Q0 Q0
. Q1 . Q0

Q0 Q1 Q2
) (last queue





8B:=> ?9@ 1A89: 45212



(Shortest-job-first
(Multilevel feedback )(Round-Robin )(First come first served
)scheduling
)queue

 CPU      
burst   

  CPU burst

 
 o#&~([ &#f
(Multilevel feedback
)(Multilevel queue
)queue

 
 
 
 
 
 
 
 

8B: Multilevel Queue & Multilevel Feedback Queue?9@ 1A

 



&)UOm "U& Ucu& M$"d&( # OX&( X $&( f Uf&[ X(* UXi& W*(
MXud& c M*U[ u - c%&[ X o"(X%&
:;<@?>
Operating System Concepts
https://www.it.uu.se/edu/course/homepage/oskomp/vt07/lectures/scheduling_algorit
hms
http://www.personal.kent.edu/~rmuhamma/OpSystems/Myos/multQueue.htm
http://en.wikipedia.org/wiki/Multilevel_queue
http://cs.wwc.edu/~aabyan/352/Scheduling.html
http://www.cs.jhu.edu/~yairamir/cs418/os2/tsld039.htm
http://www.mines.edu/Academic/courses/math_cs/macs442/resources/S9schedul-
Part2.pdf
http://en.wikipedia.org/wiki/Multilevel_Feedback_Queue
www.student.cs.uwaterloo.ca/~cs350/S04/notes/sched.pdf
)( Multiple-Processor Scheduling

) ( one CPU
) (multiple CPUs!
(many
) CPUs .

) (homogeneous processor
) (heterogeneous processor

.1 ) :(Homogeneous ,
) ,(register )
. (motherboard .

.2 ) :(Heterogeneous .

.1 ) : (Load sharing
) cup
(schedule .

.2 ) :(Asymmetric multiprocessing
, ,
,

) (master
) ( slaves
).(master
:
.1 )(master
.2

.3 )) : (Symmetric multiprocessing (SMP


,

.
:
.1

) (mutex
.
) (
.
.2
.3 )(deadlocks
.4 )(time slice

:
.1 ) (queue
.2 ) (queue

*)( &U"P$ (&"[ &U"|X s)S Md&U$[


@?><;:
Operating System Concepts
http://www.cse.sc.edu/
Thread Scheduling

) (user thread ) (kernel thread


).(thread
) (thread ) (process
) .(kernel thread

): (threads

: Local Scheduling (process-contention-scope


) PCS

) (thread library
) (kernel ) , (LWP )
(LWP .
) (c :
PTHREAD_SCOPE_PROCESS

: Global Scheduling (system-contention-scope


) SCS

) (kernel ) (kernel thread


) (CPU .
PTHREAD_SCOPE_SYSTEM :
[U$& s)S
:;<@?>
Operating System Concepts
http://www.cse.sc.edu/
:

)(Deadlock

..
.
. .
.

)(Deadlock

:
-1 .
-2 .
-3 .
-4 .

)(norah_gaissi@hotmail.com


.


- -
.

:
:

-1
-2
-3
-4
!!
:


.

:
... ..
.

) (preemption ...

:

..

):(Resources

:
)( , .
.

.

-1 ) (Preemptable .
-2 ) (Non-Preemtable .
:

.

:
.
" ,

-1 : ) (
.
-2 : .
-3 : .

-1:( Mutual exclusion )

.
.Deadlock

-2 )( Hold and Wait


-
-3 ):(no preemption
.
-4 ):( Circular wait

.....

**
.

()Resource-allocation graph


:
-1= },1,2,3 { 4 .
-2= },12 {3 .

.

.
.

.

**:

,1 1 2 .
2 2 .3
Deadlock. 3 3 2
:
<-2 <- 2 <- 3 <- 32

(1 ):(Ignore the problem



.
) (.
(2 ):(Deadlock Detection

. instance
. cycle
(3 ):(Deadlock Prevention
.
(4 ):(Deadlock Avoidance
.
.

** deadlock prevention deadlock


avoidance .
.

.
:
.
.
Banker
-
.

:
.
:
/1 .
/2 .

/ :

.
.
/1 :

.
/2 :


.
.

.
.

.
:
/1 /2 . /3 . /4 .
/5 . /6 .
.
/ :

.
. 3:
/1 : .
.

/2 :
.
/3:



.

***

-1 ,
, :
-
, , .
- ,
, .
- ,
,
.
-2 Constrained Allocation
:
-1 Standard Allocation
- 2 Controlled Allocation
, .
.

-3 Detect and
Recover
, ,
:
):(Resource assignment table -

- ) :(process wait table


.

* :

1968
):(Dining Philosophers


.. ..


)(http://www.doc.ic.ac.uk/~jnm/book/book_applets/Diners.html
. :

.
.

" "Restart . ""Freeze


...

-
.

-
.

-
.

.

.
.
.

http://www.doc.ic.ac.uk/~jnm/book/book_applets/Diners.html
http://www.doc.ic.ac.uk/~jnm/book/book_applets/FixedDiners.html




http://courses.cs.vt.edu/csonline/OS/Lessons/Deadlock/index.ht
ml

http://en.wikipedia.org/wiki/Dining_philosophers_probl
em

Operating system concepts Book by Silberchatz Galvin Gagne


http://www.math-
cs.gordon.edu/courses/cs322/lectures/deadlock.html

http://www.cs.jhu.edu/~yairamir/cs418/os4/sld003.htm

Operating system concepts Book by Silberchatz Galvin Gagne

http://www.math-
cs.gordon.edu/courses/cs322/lectures/deadlock.html

http://www.cs.rpi.edu/academics/courses/fall04/os/c10/index.ht
ml
http://www.math-
cs.gordon.edu/courses/cs322/lectures/deadlock.html

http://www.cs.rpi.edu/academics/courses/fall04/os/c10/index.ht
ml
http://en.wikipedia.org/wiki/Deadlock
http://www.math-
cs.gordon.edu/courses/cs322/lectures/deadlock.html
http://www.cs.jhu.edu/~yairamir/cs418/os4/sld003.htm


http://www.math-
cs.gordon.edu/courses/cs322/lectures/deadlock.html


http://en.wikipedia.org/wiki/Deadlock
http://www.math-
cs.gordon.edu/courses/cs322/lectures/deadlock.html
http://www.cs.jhu.edu/~yairamir/cs418/os4/sld003.htm

http://courses.cs.vt.edu/csonline/OS/Lessons/Deadlock/index.ht
ml


:


Memory Management and Virtual
Memory

) (RAM


.


) (processes

.








52
.
)(afnan.s@gmail.com

1 Operating System Concepts by Silberschatz, Galin and Gange.



:




.

) (:

) (virtual address space
) (actual address space




-
) (logical address
) (pages


).(Memory Management Unit
) (



) backing
.(store

,

53
.
) (


.


.
) (





.

) (backing store
54
.

1
en.Wikipedia.org

1 Microcomputer Operating Systems book, Operating System Concept book.


) (

:
Paging
Pages
Demand Paging in Virtual Memory

) (


.

Lazy Swapper
Pager Swapper
Pager Pages .

) ( Page-fault Pager
.


55
.
) - (

55
En.wikipedia.org and www.science.unitn.it

) (Secondary Storage (Physical
)Memory .

)(




.

:
) ( bit
) .(Page Table
:
-1 ) : (valid .
-2 ) : (invalid :
. ) (.
. ) . (

) ( :
-1 ).(invalid
-2 .

) (pager

.
" "
) (Trap ) (Page-Fault Trap
.
:
) (Frame
.

) (Page-Fault

56
).(Pure Demand Paging
) (


- :

.

- :
.

- : .

- :
)(copy-on-write
,
57
.
56
Operating System Concepts by Silberschatz, Galin and Gange.
57
En.wikipedia.org
:
: )
( PCB
) (valid
) (invalid
.
:
) (

.
: ) (frame
).(free-frame
: .
:
.

: .

58
.
) - (

---
: Copy-on-Write
)( Fork
)( )(

58
Operating System Concepts by Silberschatz, Galin and Gange

)( exec .
) (COW

.

) (process1 - child ) (process2- parent


A B C
) (process1 ) (C
) (process1 .

) (
:




)( .
) (

-1

) (frame ) (victim ) back
(store
.


).(basic replacement
) (
:
-1 .
-2 :
.a .
.b
.
.c
.
-3 .
-4 .
) (
)
(
.



) (modify bit or dirty bit
1

) (
) (

.

)frame-
(allocation algorithm
) (over allocation
).(page replacement algorithm


) reference
(string
) ( .
) (
-2 FIFO



) (FIFO queue
) ( .
) (
:

- 7 0
1 .
-
7 2 .7
- .
- 3

3 .
-
15 .
) (


).(Beladys Anomaly
) (


.
) (
:

).(f

9 .
) (
-3








.
) (
:
-
.
- 2

1
7 7 2
.7
- .
- 3
1
2 1 .3
- 9
.
) (

9 .
-4



.

.
:
- : 7 1
.
- : 2
7
.2
- : .
- : 3 3
1 2
1 .
- .
) (


:
- :



.

- :stack




.
) (

-5
) (
) (reference bit 1

1
1


.

-

1
) (
1


.

1
1
) (
.
) (

-6

.



- :




.
: -

.


.
) (
:

: 11.1 :

) ( disk
) ( secondary storage :
.1 :

.
.2 .


.
) ( I|O byte
) ( RAM blocks
. block ) ( sector) (59
.

.
:
: .
:
.

) . ( 11.1

59
( & 4,069 s cWn U !S&UQ Z vXu( &UQ U (S vXu"! sector 32(Om &
( = 4. (& (S ( $~c 512(.
=ST: :11.1 IJK8 8QA 8MNO2

11.2

11.2.1 :

1-on-disk

2-in-memory

on-disk:

boot ,
) , ( blocks , .
:

: boot control block


). (boot . UFS
.boot block NTFS. partition boot sector
: volume control block blocks
FCB . UFS
superblock NTFS master file table
 : UFS
NTFS . master file table
 FCB
blocks UFS. inode NTFS master file
table

in-memory:

: in memory mount table .1 .


: in memory directory structure cache .2
.
system -wide open-file table .3 FCB
.
per-process open-file table .4 system-
wide open-file table .

FCB :

UNIX
.

WINDOWS NT
) ( system call .
: 11.2.2 ( Mounting and Partition) :

:
: .
,
.
,
1 24 C: . z:


.
) (GB30 GB 25
C: windows 2000 GB5 D
.
.
.
:

MBR(Master
) Boot Record ) . (Partition Table
, ) boot
. (sector MBR .
MBR BIOS .
MBR , .
) active( ,
MBR .
, .
.

.
) . (volume boot sector ,
, .

, .
: ) (primary .Extended
. .

:
,
. MBR .
. windows 9x
, FDISK .
Microsoft .
, . windows 9x

Linux , windows 2000


.
,
RedHat : .
. Linux,windows98,windowsXP , windows2000,
,
system Commander 7 .
windows 2000, Linux , system
. commander system commander MBR
.
,
.
windows 98 . C: , Linux
. windows 2000
, Linux
.

:
,
MBR ,
.
system commander
. ,
,
. .
.


) . (Extended Partition
, .
. .
, .
.
. ,
) windows
( 9x 24 ) A,B
( . ,
, . ,
. ,
.
, ,
.
:



.

.

.

FAT32 EXT3

NTFS FAT32 LINUX


NTFS

...



,
) (C,D,E,F,G,H,I
ATA
.hda1 , hda5 , hda6 , hda7 , hda8

, partition

$fdisk -l

Device Boot Start End


Blocks Id System
/dev/hda1 1 388
2933248+ 83 Linux
/dev/hda2 389 557
1277640 5 Extended
/dev/hda5 389 557
1277608+ b W95 FAT32

) shell
( :

$mount
/dev/hda1 on / type ext3 (rw,errors=remount-
ro)
tmpfs on /lib/init/rw type tmpfs
(rw,nosuid,mode=0755)
proc on /proc type proc
(rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs
(rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs
(rw,nosuid,nodev)
devpts on /dev/pts type devpts
(rw,noexec,nosuid,gid=5,mode=620)
nfsd on /proc/fs/nfsd type nfsd (rw)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type
rpc_pipefs (rw)

, , hda5
:

mount point
.

dev/hda5/

mount
point
mount :
/mnt ,/media


. root

$mkdir /mnt/xxxxx

hda5 :

$mount -t vfat /dev/hda5 /mnt/xxxxx

11.2.3 :

:
) ( kernel
system calls

,
windows,
mac os & linux
.

) ( ,
.
sun os unix
sun microsystems
unix UFS NFS

:
http://web.mit.edu/tytso/www/linux/ext2intro.html
http://209.85.129.104/search?q=cache:VkZOKtxXbiwJ:wapedia.m
obi/en/Virtual_file_system+virtual+file+systems&hl=ar&ct=clnk&
cd=31&gl=sa
Operating Systems Concepts

Directory implementation 11.3


) ( Linear list



block

,
.

..

:
0 ) ( mark
\
0
0
.
.

)( Hash Table

hash data structure


, .

) ( linked list
.

:


11.4 :

..

-:

-:

(Contiguous Allocation) -:

) (address
)(block

-:
) (disk address ), (disk
)( accessing contiguous
.

)block
(address of first ) (

) (blocks
) (blocks .


) (blocks
.

) ,( First-fit ), (worst-fit ) (best -fit




) ( First-fit .

:
*
,external fragmentation
,
.
* ,
, ,
!
) (
) (blocks
.

-:

) (blocks
-:

) (metadata .

) (Subsequent .

-:
-:

) (metadata .

( Linked Allocation) -:

) (linked list ) Disk


(blocks .

) (
) (null )(node .

) (block
)(linked list .

) (blocks .

)( external fragmentation
, ) (block ,

).(blocks

) (access
) (access ,
.

,
.
) (reliability
) (pointer
.

)File-
(Allocation Table ) (volume
) (blocks ) (
.

-:

(Indexed Allocation) -:


) (block )(index

,
) (direct access ,
) (external fragmentation


, index block
! .

-:

http://filesystems.palconit.com/filesystems-file-allocation-
methods.html
http://www.people.fas.harvard.edu/~lib215/lectures/lect_p/lec
t04/6_Extras/bar_fs/index3.htm
Silberschatz, Galvin, Gagne: Operating System Concepts

11.5 ":" management Free space





.


)(.Free space list
)(free disk blocks

) . (

. .
.

.1 ""bit vector
.2 ":" linked list
.3 ""Grouping
.4 " " counting
":"bit vector

" "Block " ."one bit



) ( 0
) ) ( 1 1
0(

:
blocks )(2,3,4,5,8,9,10,11,12,13,1617,18
blocks bit map


""bit-manipulation instruction

:
.
microcomputers
.
:
block 2Kbyte 1 Gbyte
bit vector 1GB/2KB=32KB

": "blocks
block )( word bit map
block )(bit 1
block = ) bits * word words
( offset + block

:
word 5 bits
bit map :

block =) 17 = 2 + (3 * 5
":"linked list


.

..

, 2 .
3
4 5 8.

* ) (

* .

/
.
* .

* " "block front .

:
blocks ) (2,3,4,5,8,9,10,11,12,13,17,18
blocks linked list

":"Grouping

* .

* .

blocks n block
blocks ) n-1 (
:
blocks

:
blocks ) (2,3,4,5,8,9,10,11,12,13,17,18
blocks (n=3) grouping

":"counting


)(contiguous blocks
) contiguous
(allocation
n ) (.
.

:

)+(
.1


blocks ) (2,3,4,5,8,9,10,11,12,13,17,18
blocks counting

:
www.ece.iupui.edu/~dskim/Classes/ECE408/ln-
os-ch11%20File-System

http://filesystems.palconit.com/filesystems-free-space-
management.html

http://blog.pixnet.net/nixchun/post/7989490

Operating System Concepts

. Khadija akherfi 
. 
. 

: 11.6

Buffer Cache / page Cache / Unified Buffer Cache


) ( :

Memory mapping .1 )(mmap

)(Virtual Memory subsystem

I/O system calls .2 )( read )(Write

(I/O subsystem).

Disk Cache

Disk Cache

Buffer Cache .1

Buffer cache ) I/O system calls ( )


(.

Buffer Cache
.
:

.

.


.bits Sectors
Sectors
)(Blocks Buffer Cache
.

:Buffer Cache

Bits Buffer
Cache .

Page Cache .2

Pages
Block
. blocks

Two cache model .3


Buffer Cache Page Cache

- ) Buffer Cache (I/O system calls

Buffer Cache
.

Buffer Cache
.

- )page cache (memory mapping I/O

Buffer Cache
page cache
.

page cache Buffer


cache .

.1 ) (
.

.2 ) page cache (Buffer cache

:
)
page cache
Buffer cache !(
Unified Buffer Cache

Unified Buffer Cache(UBC) . 4

page
cache buffer cache
.
:

http://searchstorage.techtarget.com/sDefinition/0,,sid5_gci21
1963,00.html
http://www.faqs.org/docs/linux_admin/buffer-cache.html
http://www.usenix.org/publications/library/proceedings/useni
x2000/freenix/full_papers/silvers/silvers_html/
Operating system concepts-6th ed(page 434-435)
:

Mass-Storage Structure

, : .

.
.


. .

 .
 .
 [im()S(S ( & o"i&W#n [SQX &WZ! . RAID [ )XS ,


.
)(l.bishy@gmail.com
1-12 :

:
.

1-1-12 :

) ( platters

: / , .

,( sectors ) . ) ( tracks

, 512 .

) ( arms ) heads
(

) / (
.
( cylinder ) . :

( Platters ) . ( cylinder
)

) ( .
.

 :

( ) :
.


)
( .

: .

250 - 70
:

 4200 : IPod

 4200,5400 : 7200

 7200 :

 10000 : 15000

:
 ):(Transfer rate

) ( .

 ) ( ):(seek time

) / (
) (track .

 ) ( ):(rotational latency

/ ) (sector
.
 ): (Access Time

/
.

= ) + (seek time )(rotational latency


 ) ( ) :( positioning time

) ( )
( .

) ( .

. 

 .

 .

 )
(.
:

) : (Head Crash 

- ,
-
) ( ,
.


.
.

)
(
.


:
.
.

.

SCSI

\ .

/ ,
,
, .
: 


120 .

) . (EDB
.


EIDE,ATA,SATA,Fireware,USB,Fiber Channel,SCSI:

) ( Host Controller :
.

:
IDE ATA Internal Hard Disk  :

) :( Integrated Drive Electronics IDE

Parallel ATA . PATA

GB 200. 4 GB .


SATA.

SATA Internal Hard Disk  :


SATA

( Serial Advanced Technology Attachment. )

IDE .

SCSI Internal + External Hard Disk  :

SCSI

( Small Computer System Interface . )

) ( :



" :
" . ,
3 .

( . )

 EIDE

" " IDE " :

" . ) (
.

( . IDE
) ( IDE

IDE
.

EIDE IDE :
. IDE IDE
CD DVD .

 SATA
.

 SCSI


.
IDE )
( - - IDE

.

IDE IDE

.
.
.


2-1-12 :

):(access time

):(random access

,
.

:
.

- - - -


) ( Operating System Concepts
) (CompTIA A + Certification
WWW.IFOREX.COM
http://www.sanabes.com/
http://www.dcs.ed.ac.uk/home/stg/pub/D/disk.html

2-12 :

(Hard Disk ) ,
) ( Servers

.

.


) ( Formatting the HDD
.

 ) ( Low Level Formatting

( Physical Formatting ) .

 ) ( High Level Formatting

( Logical Formatting ) .

WWW.IFOREX.COM
3-12 :

) ( (I/O ports)

. ) (
.

1-3-12 - ): (NAS
)(.Network attachment storage

- ):( NAS protocols

) (NAS)(servers ) (NFS
) (CIFS ). (FTP

- ): (NAS connections

) (NAS .
2-3-12 - ): (SAN

)(Storage area network

)(WAN)(LAN

)(servers

:SAN

SAN
) (Tape libraries) (disk arrays ) (optical jukeboxes )
(Servers ).( Locally attached

- 2007 SAN
) .( Enterprise

:SAN

: (Fiber Channel )FC iSCSI


.IP-based SANs

SAN iSCSI
.
(Direct Attached Storage )DAS .NAS

redundant
NAS

) DAS DAS
.(Hard Disk

SANs
.

SAN
) (Servers )
( boot ) SAN (.

:SAN

SAN

:SAN
).(Fiber Channel

SAN K$50-60 .

SAN iSCSI ) K$20-30


(
6.

iSCSI
.

SAN

3-3-12 - ) (NAS - ): (SAN

)(NAS) (SAN
:

NAS and SAN


NAS SAN
- ).(NAS - .

- -
. NT .

- ) (server ) - SCSI fiber


(channel ) (SAN ) (LAN
).(WAN ) (fiber channel 10
.

http://en.wikipedia.org/wiki/Network-attached_storage
http://www.nas-san.com/differ.html

4-12 :

) (
.
.

) (controler

). (queue

.

) . ( scheduling policies


: , .

 ) : ( acess time

(seek time) . :

( rotational latency). :

 ) (disk bandwidth

) throughput (

) response time (


) ( scheduling .

head
.
.

: ) : ( FCFS 

) ( FCFS ) ( First Come First Serve )


(


, .
.
.
.

) ( queue ) (

)( :

76,65,124,14,122,37,183,98
53 53 98
45

) ( 45=53 - 98 98 183 85
. 67


53 98 183 37 122

67 . 14 124 65

tota head movment = | 53 - 98 | + |98 - 183 | + |183 - 37 | + |37 -


| 122 | + |122 - 14 | + | 14 - 124

| + | 124 - 65 | + | 65 - 67

= 45 + 85 + 146 + 85 + 108 + 110 + 59 + 2

= 640 cylinders

640
.
: 37
122 14 . 124 ( wild jump
).

37 14 122
124 .

: FCFS

. 

. 

 .

 .

: ) ( ) 
: (SSTF
) ( SSTF ) ( shortest-seek-time-first )
(

.
.
.

. (
)
, ,
, .
.

53

| 53 - 65 | = 12, 65

67

|67 - 37 | = 30 37 : . |67 - 98 | = 31:


37 98
14 98 122 124 . 183

| tota head movment = | 53 - 65 | + |65 - 67 | + |67 - 37 | + |37 - 14


| + |14 - 98 | + | 98 - 122 | + | 122 - 124 | + | 124 - 183

= 12 + 2 + 30 + 23 + 84 + 24 + 2 + 59

= 236 cylinders

236
.
37 53

37 14 65 67 98 122 124 183

208 .

) .( starvation

: .
 : ) (: (SCAN ) -

) ( arm
,
.

) ( .

) ( ) (.

: ) ( elevator algorithm

.
 : ) (: ( C - SCAN ) -


) (
.

, .
) ( circular list
.

tota head movment = | 53 - 65 | + |65 - 67 | + |67 - 98 | + | 98 - 122


| | + |122 - 124 | + | 124 - 183 | + | 183 - 199 | + | 199 - 0 |+ | 0 - 14
| + | 0 - 37

= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 199 + 14 + 37

= 396 cylinders
 : ) : ( LOOK

) ( scan ) ( c-scan
.

)(
. .

) ( scan ) ( c-scan LOOK : C-


LOOK
:
tota head movment = | 53 - 65 | + |65 - 67 | + |67 - 98 | + | 98 - 122
| + |122 - 124 | + | 124 - 183 | + | 183 - 14 | + | 14 - 37 |

= 12 + 2 + 31 + 24 + 2 + 59 + 169 + 23

= 322 cylinders

- - - - -
- - -

Operating Systems Concepts book


http://www.dcs.ed.ac.uk/home/stg/pub/D/disk.html
http://www2.cs.uregina.ca/~hamilton/courses/330/notes/io/no
de7.html
http://www2.cs.uregina.ca/~hamilton/courses/330/notes/io/no
de7.html
:
http://gaia.ecs.csus.edu/~zhangd/oscal/DiskApplet.html

) 6-12 Swap-Space Management:(


( swapping ) ,

.
.

)( Virtual Memory techniques

) ( .( processes ) pages

( 1-6-12 Swap-Space Use):

) (:

)
(
.

* M &cXc c P ! & &Wu & !S OQX&UQ &| ["X on &$ o& ) : s
( Swap-Space

)(*(swap-space &$ o(%S c[ !S [dOQ%S&UQ &| - U c& [""Z" &U &- ["%"hU
["Xd& [||ZS&$ o !~X($ Wn & oX~SU &. ["%"hU
( swap space
) .

( throughput ) ( swap space


) , .
) ( swap space
:

( Paging system).

, .

( sawp file) :
.

RAM .

( 2-6-12 Swap-Space Location: )

 )(file

( external fragmentation ) .

 )(disk partition

%20
.

Mount

( 3-6-12 Swap-Space Management :Ex: )

) :( swap space

..

 ) : ( Device swap

) ( Device swap space


.

) ( space ) .( dump area


) ( Device swap . )( clien t
NFS .

) ( Device swap
.

 ): ( File system swap

( Device
) .swap space ) ( file system swap )
( device swap space ..

) ( file system swap




) . ( device swap device
). ( swap space

) ( )
( cluster clients .
,
) ( device swap .

): ( Pseudo-Swap 
) ( pseudo swap
) ( paging .

) ( pseudo swap space


swapmem_on, to 0 tunable system parameter
((off

( 4-6-12 Swap-Space Management :Ex: )


)( .

. ( swap-space ) Linux


4
:

(page slot).

swap area) ( .

(Page slots) . ) ( swap area

) ( ( page slot).


 ) (

) ( 1 )( page slot


 ) ( 3 :

3 ).( swapped page

) ) (
4(. 4
:

- - - -

operating system concepts


http://docs.hp.com/en/B2355-90672/ch06s02.html
:


)(I/O system

:
.1 ) (
.
.2 ) interrupt

,
) .(( interrupt handler

...
.1 .
. .2
. .3
. .4
. .5

: :
. : .
. .
. .
. .

: :
:

) (Port - a connection point .

)(Controller .

(Memory-mapped I/O) . .

(Direct I/O instructions). .

.
: :
.
:

)(Character-stream or block

) (Sequential or random-access .
)(Synchronous or asynchronous .
) (Sharable or dedicated .

) (Speed of operation .

(read-write, read only, or write .


only

: :

....

.1 .

.2 .

.3 ) (buffer )(disk.

.4 .

.5 .

::

:
.1 ).(switches

.2 .

.3 (interrupts). .

.4 ),(CPU,.

Operating System Concepts by Silberschatz, Galvin and


Gagne

)( open(), read(), write:

ANSI C

fopen(), fread(), fwrite() :


:

: , .
: .

(System call I/O).1 .

(stream I/O).2 .


) (
, :

.1Open() .

, .2 write().

...
.

:
,

.

- :


.

.
.

http://www.enterprisenetworksandservers.com/monthly/art.php?1503:

,
, , , .


(Device management).

.1
)) (control block unit(CBU
.
.2
) ,,(
.3 .
.4 ,
.

:
:
.1 )(Dedicated I/O Devices
.2 )(shared I/O Devices
.3 )(Virtual I/O Devices

:
.
, :
, ,

.

:
, ,
:
)).(Direct Access Storage Device(DASD
.

.

:
,
) (spooling system
, ,
:
.1
,
,
,
.
.2
.

.
)(IO\channels


.
) ( )(program channels
/ .
.

:

)(interrupt

: ,
.

interrupt:

interrupt-request line
. ,
" " interrupt handler
. interrupt handler ) (
,
. " raises"
. " catches" ""dispatch
interrupt handler clear .

interrupt handler :

_1 interrupt handler .
_2 interrupt handler
" polling" .
_3 interrupt
.
* ,

"".

microprocessors .

.
.
CPU .
CPU .A special set of registers
CPU CPU

:
http://www.science.unitn.it/~fiorella/guidelinux/tlk/node81.html
:
)(interrupt

) interrupt(: hardware
.code

* ) interrupt( : )
(.
* MSP interrupts

) interrupt( :
maskable- 1
non-maskable 2

: Maskable interrupt
.

:A non-maskable interrupt ,
)interrupt( .

* maskable interrupt
.
* ) interrupt( " " ) (2 interrupts
) interrupt(
)interrupt( .

:
http://cnx.org/content/m12321/latest/:

: interrupt

-1 :nonmaskable interrupt
.

-2 :maskable interrupt

. .

Operating System Concepts by Silberschatz, Galvin and Gagne 7th edition


)(interrupt

Interrupt request line:


CPU & controller CPU
controller

CPU context
switch Interrupt handler
memory
Interrupt handler Interrupt
CPU CPU .

:interrupt

Non-maskable interrupt: -1

.

Maskable.2

CPU
.

Interrupt vector:
Interrupt handler
handler
interrupt .
Interrupt priority levels:
CPU

Boot time .1 CPU


Interrupt vector
Exception.2 Software .

: Operating System Concept


)(interrupt

interrupt
handler :

..1 .

.2

.3 .

.4

.5 .

:I\O interrupt

.1

.
.2 command word
channel HIO
.
.3

Spooling system
.

)(Direct Access Memory

:Direct Memory Access


.CPU

:Module .
* CPU.
* ADC, DAC, PWM, memory
..

* : DMA
.
Memory
peripheral systems data registers
control registers ..
DMA memory bus
memory .

:DMA .. memory bus


independent triggers , memory regions

.. DMA trigger
signals .. signals ..

: DMA controller trigger signal ..


memory bus non-maskable interrupts
Controller simultaneous triggers

:
:/http://cnx.org/content/m11867/latest

.
)(DMA :


)._(DMA
)( )(
.
)(
.
)(
.

http://en.wikipedia.org/wiki/Direct_memory_access:
):(DMA
CPU , Bios .
I/O CPU RAM
, RAM , CPU
CPU RAM .
, , CPU
.
, Cache memory CPU
.CPU

:
?CPU
Direct Memory Access : CPU


/ ))..((CPU

DMA , . CPU
, .RAM

hardware DMA )) disk


((drive controllers ..

channels DMA
)).. ((CPU
, DMA )) ((CPU ,
, )) ((interrupt DMA ,

)) (( real-time
..

: DMA
CPU
DMA )CPU (

IBM 8237 .DMA


, RAM .
. CPU




http://en.wikipedia.org/wiki/Direct_memory_access:
) (polling

)(Polling

.
. ) (
.

) (poll
.

Polling
) (CPU ).(controller

Controller Busy Bit status register

controller (write 1 on it)set busy bit


(write 0 on it) clear to busy bit

controller CPU
controller command-ready bit in command register

:
Busy bit 0 controller
set to write bit in command register byte
data-out register set command-ready bit

controller ready bit has been set set to busy


bit
controller command register write
)set (1

controller ) (clear command ready bit


error bit busy bit
.


: Operating System Concept

Vous aimerez peut-être aussi