-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos.txt
executable file
·71 lines (60 loc) · 3.35 KB
/
os.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
OS: {
"Resource Manager": share hardware between multiple processes,
"protection": run each process in isolation,
"Abstraction": provide api [system calls] to faciliate interacting with hardware
}
OS_TYPES: {
"Single Tasking": ms-Dos[Inefficient],
"multiprogramming & multitasking": ,
"multithreading":
"multicores",
"multi-users": allow multiple users to log into os and use it simultaneously
}
program : file resides on the hard disk.
process : when the file loaded to the memory to be executed
- stack - heap - text/code - data
Process vs Thread
Thread: Stack + share from its process [Code, Data, Files, Heap]
- cheaper to create and terminate
- multiple threads in a process
* share address space
* easier to communicate
* cheaper context switching comparing to processes.
Process: Code, Data, Files, Heap, etc
----
User Thread vs kernel managed threads
management: process create threads kernel is not | - In kernel space
aware of them.
context-switching: fast | - slow
Blocking: one thread might block all other threads,| - a thread block itself only
can handle that using a jacket. |
|
multicore: cannot take advantage of multicore sys. | - take full advantages of multicore sys.
only concurrent execution on single |
process
-----------------------------------------------------------------------
Mapping of user threads to kernal threads:
One To many --> work as kernel threads
ManyToOne --> multiple threads in one process mapped to one kernel thread
manyToMany --> rare
single-program-sys: new -> running -> finish states only. most of the time the cpu will be idle.
multi-tasking : a multi-programming system where time sharing is used to allocate processor to
different processes. each process has a slice to make use of cpu then become waiting. and the next process take place.
multiprogramming: allow multiple processes to exist in memory and running them in interleaved fashion interchangeable.
process states in multi-programming system:
<--timeout/hPrio-
[DISK][[New]]-->[RAM]Ready --dispatcher---->[CPU] [[Running]]---------->[[finished]][last statement/error(aborted)]
|-------[[waiting]]--------------|(i/o req)
there are to other states [[suspend/block]] [[suspend/ready]]:
- the first in case all processes are waiting, so os move processes from waiting state to disk,
to make some space in memory to begin executing other process instead of being idle.
- [[suspend/ready]] when we don't have mem to run a higher priority process we move processes from
ready state to disk.
- each OS has dedicated place to store process data on disk to reload it when it needed,
in linux there is something called swap space. win store process pages in .sys files on disk.
cpu interact with RAM, it's OS responsability to bring required data from disk to ram for cpu to operate on.
--
Process Control Block(PCB):
1) pid 2) process state. 3) cpu registers.[PC]
4) accounts info(how much cpu time used)
5) I/O info. 6)scheduling info. 7)memo info