-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreads.txt
36 lines (27 loc) · 1.31 KB
/
threads.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(IN A MULTI TASKING ENVIRONMENT,WE ONLY HAVE ONE CPU GENERALLY IN OUR
PC WITH WHICH WE HAVE TO DO MULTIPLE TASKS TO DO THAT WE MAY USE THREADS
MULTI THREADING ENVIRO IS USED WHERE ONE TYPE OF PROCESS IS RUNNING
A LOT OF TIMES
EXAMPLE IF I WANT TO PUT A THING IN ONE HAND TO ANOTHER HAND
WE CAN DO IS MAKE OUT CLONE WHICH WILL DO IT (CHILD PROCESS USING FORK
IN WHICH NEW DATA IS BEING CREATE WHICH IS CLONE OF ORIGINAL)
BUT WE CAN ALSO SIMPLY JUST MAKE ANOTHER HAND ON THE MAIN BODY AND
MAKE IT DO IT(WHICH MEANS ALL THREADS SHARE SAME DATA AND CODE
BUT ITS HAS OWN STACK AND REGISTER FOR EACH THREAD)
PROCESS -IT IS A HEAVY WEIGHT TASK
SYSTEM CALLS IS INVOLVED HERE LIKE FORK
OS TREATS DIFFERENT PROCESSES DIFFERENTLY
DIFFERENT PROCESSES HAVE DIFFERENT COPIES OF DATA
CONTEXT SWITCHING IS SLOWER
BLOCKING A PROCESS WILL NOT BLOCK ANOTHER
INDEPENDANT
THREAD-IT IS A LIGHTWEIGHT TASK
THERE IS NO SYSTEM CALL,
ALL USER LEVEL THREADS ARE TREATED AS SINGLE TASK FOR OS
THEY SHARE SAME COPY OF CODE AND DATA BUT NOT CPU REGISTER AND STACK
CONTEXT SWITCHING IS FASTER
BLOCKING ONE THREAD BLOCKS ENTIRE PROCESS
INTERDEPENDANT
NOTE THE CONTEXT SWITCHING FOR THREAD IS NOT FOR LIKE IN PROCESS AS IN PROCESS
THE WHOLE PROCESS IS CHANGED AKA THE DATA CODE AND EVERYTHING BUT
IN THREAD ONLY REGISTERS AND ADRESSES ARE CHANGED SO ITS FASTER