HW 4
HW 4
HW 4
B 104020046 單業儒
/ 3
Kernel threads .
On M M N
systems usingeither 1 or
mapping
: :
aregenerally
more expensivetomaintain than user threads
because they must be represented with a
use the
inferleaving time in a useful manner .
Single -
threaded process :
suffer
in scenarios where a
program might
from frequent page faults or has to waitfor
other
system events, a
mulithreadeds 0lution
would perform better even on a
single
processor system .
#
A : b ,
c
'
heapmemory
才
variables
global
吿 負責分配任務給threads 的系統
1 .
Pata parallelism 2 .
Data parallelism
3 . Task parallelism Data parallelism
4 .
5 .
Task parallelism1
言
!
'
sine file
the must be accessed sequentially
,
the work of reading and writing it cannot
2
The CPU intensive porion should bedivided
-
resources ,
while more threads would be
unable to run
simultaneously .
#
活
I
The initialcalltofork ( )creates aopy of
the original process ( 2 processes now ) ,
( 3 now )
processes ,
3
There two processes execuing the
are now
( 3 processes 2 threads )
,
4
A 11 three processes execute the final call
to fork ( ) ,
so each
process opies itself at
that ( 6 2 threads )
point ,
processes ,
,
a 6
.
processes
b 2 threads
,
¢
LINEC =
5
LINEP =
The only time that a child process writing to memory also makes changes in
the parent process's memory is when the memory written to is explicitly
shared memory.
the parent (
process they don't have shared
momory) .
b lan of processing
.
fully ultilired .
)
、
c .
All of the processes will be working
simultaneously assuming there
areenough
user threads .
If a Kerne 1 thread is blocked ,