You are on page 1of 9

j

()8

Process Synchronization
: )Logical Add Space (
( )order ( . )Data Consistency
Share data Concurrency data inconsistency data consistency . Process Synchronization

: product & consumer problem bounded memory buffer Concurrency :


Counter ++

& Counter --

. interleaving

* ( : Race condition )

( )1 . Concurrency
( )2 ( ) .
* .

: Counter ++ :

& Counter -- atomically

* : Atomic operation .
* Race condition ( ) .
10

.........

Rear
()
In ==== Next free slot

.............

=== Next file table print

Front
()
Out

:
* ( )printer spooler . slots
* ( )Printer daemon ( Module ) Next file table print
Out .

* A & B M A . S B
Front Front Rear . Rear

)A( M Rear ( )10 ( )X X= 10 cpu )B( ( ) B Rear

)10( ( )Y Y= 10 .
- ( )Y ( )10 )Y( Y= 10 11 = Rear

)A( ( )X )10( ( )10 ( )X 11 = Rear ( )S ( )B


overwriting .
( : ) Critical Section
.
: ( Share date )

Certain memory location

( )
process ) Critical Section ( ( )Critical region .

( +)

Each process has a code segment , called critical section in which share data is accessed and changed
The remainder of the process code is called the remainder section .

* ) Critical Section ( .
/ . Mutual Exclusion

Mutual Exclusion
.
:

: .

( )1 : Disabling Interrupts
timer Enabling . timer
( )2 : Mutual Exclusion With Busy Waiting

Lock - Variable

( )1 & 0 ( ) check Lock -Variable

)0(

( )1 ( . )0 )1(
. Busy Waiting

Deadlock
( )source ( )
( )1 : Mutual Exclusion ( . )

( )2 : Hold and Wait .


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

( )
B

P1

P2

)p2( ( )B .

)p1( ( )A .

( +)

( )1 : Ignore Deadlock Ostrich Algorithm


( )2 : Detection & Recovery ( )killing
cycle . graph
: .
( )3 : Deadlock Avoidance
( . Banker's Algorithm ) .

()9
Memory Management :
CPU
Memory Manger :
( )1 :
.
.

( )2 ,
( )3 .
: HD Main )terminate( Main . HD
* ( :

)
** :
( )1 Mono Programming
( )2 Multi Programming

( )
.
Process

Operating system
** :
( )1 ( )
( )2 CPU . I /O Devices
( )3 .
** :
( )1 Volatile Memory . Main Memory
( ) 2 Non Volatile Memory . Hard Disk
:
On line hard disk Off line - Magnetic tape magnetic disk

( +)

**

: Memory Management with fixed partition


:

( )1 Waiting Queue

( )2
( Internal Fragmentation ) FIFO
( Memory Manger )
Starvation
:
() ( )skips ( )8 .
() Partition .
* External Fragment Partition & Partition ...

/ 50

:

* :
( )1 . .
( )2 Main Memory H.D
O. S Process Killing Dead Lock .
* Memory Manger
.
(( First Fit )1 ) : .

(( Second OR next Fit )2 ) : .


(( Best Fit )3 ) : .

(( Worst Fit )4 ) : ( . )
(( Quick Fit )5 ) :
. .
: Memory Management with Variable Partition

External Fragment
.
External Fragment Process
. Memory Compact
/
Keeping Track .
/ :
/1 ( 50 ) 489

/2 ( 489 ) 50

* ( ) . Starvation
*
489 .

( +)

:
* : Keeping Track :
) ( (1) Memory Management with Bit map :
Allocation bit .
- S.O ( )1 Bit Process ( )0 Bit.

Bit Map . Process )1( Map( )0 . 1.0 kb & 0.5 kb


1
1
0
1
0
0
1

1
0
0
1
0
0
1

1
1
0
0
1
0
1

1
0
0
1
0
0
1

1
0
0
1
1
0
1

0
1
0
1
0
0
1

1
1
0
1
1
0
1

) ( (2) Memory Management with Linked List :


List :
pointer
:

size

(process )p /h

address

)p ( Process )h( () hole


. Memory
.
List.

:
P1

P2
8

14

:
6

H
Null
(3) Memory Management with Buddy system :
( )1000 ( )500 ,500 Buddy
( . )2 , 4 , 16
1024
512

512
128

128
64 64

( +)

( )10

Devices Management :

I/O

: ,
:
( ) 1 Block Devices
( )2 Character Devices
*

( ) .

*
()
:
( )1 ( Mechanical Component )
( )2 ( Electronic Component )
Devices Controller
CPU .
? Why Electronic Component
O / S Mechanical Controller

* Block Devices Disk O / S Controller Block


Controller

Bit characters Buffer Block

Interrupt Block Block Checksum

Memory CPU O / S Low Lower task of CPUOverhead task


( Block

( Direct Memory Access )DMA Overhead

task Controller Block

:
( )1 Device Independence


.
( )2 Error Handling
Devices Controller
O / S
O / S .
( )3 : Synchronization
I / O
I / O I / O
( ) .
(: Sharable / Dedicated Devices )4

( +)


User level I / O Software

Device Independent Operating System Software

Device Driver

Interrupt Handlers

Hardware
( )1 : Interrupt Handlers


( )BIOS
.
( )2 : Device Driver

( )3 I / O Device Independent O . S Software


:
- i .
- ii . Device Naming
- iii Buffering
- iv .
- v .

( )4 : User Level I / O Software



Interface ( . )User
* :
( )1 : Programmed I / O
.
Buffer O /S Buffer

(. CPU )
()2 :
.
( )3 : DMA
Content Switch . DMA
Controller .

DMA Controller

Buffer

( +)

:
Disk Drivers
Disk Controller

Memory

Cpu

System Bus
( )1 Disk Drivers .
( Disk Controller )2
. Driver
Block
Block Seek Time
Latency time
** : Free Space Management
( )1 : Bit map .
( )2 Linked List .
( )3 Grouping
.

( +)

* * Disk Scheduling
SYS Call :
( )1 / .
( )2 ( )
( )3 .
( )4 .

( )1First Come First Serve [FCFS]


( )2 ]Shortest Seek Time First [SSTF

: Multilevel Feedback Queues Multilevel Queues


( ) .

(( ))



.

.
,
,
------------------------------------------------- 2012( )

osmansada@gmail.com

( +)

You might also like