Title: Principles of Structure of Operating Systems 046209
1Principles of Structure of Operating
Systems??????? ???? ?????? ?????046209
- ???? 10
- ???? paging (thrashing)
- ????? ??????? ?????
???? ????
2???? ?????/???
- Silbershatz ????'
- thrashing
- ?????? 5, ??? 9.7
- ?????? 6, ??? 10.6
- ???? ????? ?????
- ?????? 5, ??? 10
- ?????? 6, ??? 11
3?????? demand paging
- ??????? demand paging ??????? ???? ?????? ???????
??????? - ?? ????? ?????? ?? ???? ???????? ??????? (????? ?
ready queue) degree of multiprogramming - ???? ?????? ???? ? multiprogramming ?? ??????
??????
4?????? ????? demand paging
5????? Thrashing
- ????? ????? ???? thrashing ?? ??? ???? ???? ???
?????? (context switch, paging) ???? ??????
(???? ???????) - ????? ???? ???? thrashing ?? ??? ???? ??? ?? ????
?- paging (C.S.) ???? ?????? (????) - ??? ?? ?????
- ???? ????? ? working set
6"????? ?????" Working Set
- ???? ???? ????? ?????? ?-thrashing
- ?? locality ??????? ?????? ???
- ????? ???? ?????? ?????? ????? ????? ??????
- ???? ??????? ????? ???? (?????? ??????) ??????
????? working set - ??? ?????? working set ???? ????? ??? ??? ?, ???
- ???? ?-i ???? ????? ???? t,t-? WSi(t,?)
7The Working Set Model Denning68
- A processs working set is the set of pages in
the processs last ? page references
8Working Set Model
- ????? - locality of reference. ??????? ??????,
???? ??? ????? ?- locality ?- locality, ????
locality ??? ????? ???? (???? ????? ?????
??????) - ?? ?"? ????? ????? ???? ?? ????? ?- locality
?????? ?????? ???????, ???? ?????? ????? ????
???????? - working set ????? ?- locality ?"? ????? ?????
???????? ?- D page references ???????? - ????? (D 10)
- 261577775162341234443431243444334344
WS1 3,4
WS21,2,5,6,7
t1
t2
9?????Working Set
- ????? ?? ????? ?????? ???? ?????? ?
- ? ??? ??? ??? ????
- ? ???? ???? ??? ?????? ?-WS
- ? ? ????????? ????? ??? ???? ??????
10????? ?-Working Set
- ?? ????? ?????? ??? ????? i ?? WSi ?-WS ??????
???, ????? ????? - ?????? ?????? WSi ?????? ??? ????? i ?????
?-ready queue ?? waiting - ??-i ???? ?-WS ????, ????? ?? ?? ????? ??? ?-WS
????, ?????? (prefetching) ?? ?? ????? ?? ?-WS
???? - ???????, ??? ??? ??????
- LRU ???? ????? ??? ?-WS (????? ??-??)
- ?? ???? ? thrashing?
11Working Set ? Thrashing
- ??? ????? thrashing, ???? ? WSi ?????? ??????.
- ?? ??? ????? frames ?????? ??? ????? ?? WS ??
????????, ?????? ???? thrashing - ??????
- swapping ????? ??????? (????? ?? ????? ????
?????, ?????? ???? ?-swapped)
12UNIX process states
running user
schedule
sys. call interrupt
return
zombie
ready user
interrupt
running kernel
terminated
preempt
wait for event
schedule
ready kernel
event done
blocked
created
Swap out
Swap in
Swap out
ready swapped
blocked swapped
event done
13Long-Term Scheduling
- Controls multiprogramming level
- Decision of which processes to swap out/in is
based on - CPU usage (I/O bound vs. CPU bound)
- Page fault rate
- Priority
- Size
- Blocked vs. running
14????????
- 1960, Atlas, University of Manchester
- demand paging
- 1961-1973 MIT, CTSS
- time-sharing ?? swapping
- 1965 Dennis ????? ?? segmentation
- 1965 ?????? ???? MULTICS, MIT GE Bell
- ??? ? 1972, ????? ? segmentation paging
- ???? System/360 , IBM
- 1964 load-time binding (fixed/variable
partitions) - 1972 ???? ??????????? ?? IBM370, virtual memory
(segmentation paging), ?"? MVS
15???????? ????
- 1978 Intel 8086
- segmentation
- 1986, Intel 386 ?????
- segmentation paging
16?????? ????? ??????? ?????
17What Babylon Says
- File System (English-Hebrew)
- ????? ?????, ????? ??????? ??? ???? ??????
- File System (English-English)
- System which regulates the naming of files
18?????? ?????
- ????????? ?????? ?????? ?????
- ????? ???????? ?? secondary storage
- ?????????? ???????
- ????
- ????? directory
- ??? ????, ???? ???? ???????
- ?? ?????????? ????? (??????? ?????)
- ????? (????? ???)
19Memory Hierarchy
20Main Memory vs. Secondary Storage
- Small (MB/GB)
- Expensive
- Fast (10-6/10-7 sec)
- Volatile
- Directly accessible by CPU
- Interface (virtual) memory address
- Large (GB/TB)
- Cheap
- Slow (10-2/10-3 sec)
- Persistent
- Cannot be directly accessed by CPU
- Data should be first brought into the main memory
21Some Numbers
- 1GB230 109 Bytes
- 1TB240 1012 (terabyte)
- 1PB250 1015 (petabyte)
- 1EB260 1018 (exabyte)
- 232 4 x 109 Genome base pairs
- 264 16 x 1018 Brain electrons
- 2256 65,536 x 1072 Particles in Universe
22????? ?????? ?????
- ????? ?????? ????? ??????? ?????? ?/?? ??????
????? - ?????? ???????? ?- data ???? ???? ????? ???????
????????? - ????? ???? ??? ??????? ?????
- ??????
- ?????? ?? ???? (non-volatile)
- ???? ????? ???? ???
- ???? ?? ????? ?????? - ???? ????
- ???? ???????? ?? ???? ?????
- ???? ?????
- ???? ????? ?????
- ????? ????? ????? ?????? ??????
- ???? ?????? ?????
23File ????
- File is a named persistent collection of data
- ????? ???? ?????, ??? ?? ??, ???? non-volatile
- ????? ???? ??? ????? ???? ???? ???? ??????? ?????
???? - ????? ??? ???? ???? ????? ????? ???? (??
??-?????) - Unstructured, sequential (UNIX)
- Data is accessed by specifying the offset from
start - Collection of records (database systems)
- Supports associative access
- give me all records with NameYossi
- Attributes owner, permissions, modification
time, size, etc
24?????
- ???? ???? ?????? ????? (ADT)
- ?????? ???? ???? ??? ????? ??? ????
- ????? ??
- ?? ????? ?"? ??????
- ????/????/data
- ?????? attributes (???? ?"?)
- ?????? operations
25?????? ????? (attributes)
- ??? ????? - text, binary, archive ???'
- ????? ?? ????? ( device) ?????? ?- data ????
(??????) - ???? ( ???????)
- Owner
- ?????? (permissions) ????? ???? - ??? ????
?????, ?????, ????? - ???? ?????, ????, ????? ?????
- ???? ???? ????? ???? meta-data
- ???? ?? ?????? ???? ?? ??? ?????
26?????? ?? ????? (??"? ?????? ?????)
- ????? -(create ) ??? ???? ???' ????? ???? ??
?????? ????? - ????? (delete/unlink )
- ????? (open ) - ????? attributes ????? ????
????? - ????? (close ) ???? ???? ?????? ??????
???????? - ????? (read ) - ??"? ?????? ????? ????? ?"?
?????. ?? ????? ???? ?????? ?- buffer ??????? - ????? (write ) - ?? ?????? ???? ?????, ?????
???. ????, ????? ????? ???? ?? ???? ??? ?????
???? - ??? ????? ?????? (seek) - ??????/????? ???????
(random access) - get attributes ????? ???????? ??????? (stat)
- ?????? ?"? ?????? ????? (???? make ????? ?-stat
???? ???? ????? ?????) - set attributes (???? chmod)Â
- rename (move)
27???? ?????
- ????? ???? ?????? ????? ?????
- ????? ??? ????? ????? ?????? (????, ?????)
- ??? ???? ?? ?? (?????? ?? ?? ???? ?????)
- ????? ??"? ?"? ?? ?-????? ???????? ( extension)
- dos - ???? ?? ?? com, exe, bat
- mac - ??? ???? ????? ????????? ?????? ???? -
????? ?? ????? ?????? ?? ????????? ??????? (??
?????? ?) - Unix - ?????? ??? ????? ?????? ????
- Regular (???? ?? ????)
- FIFO (named pipe)
- directory
- Symbolic link
- ??????????? ?? ???? regular ?????? ??"? ?"?
?????? - Magic Number ???? ?? ??? ????? ?-Unix ??????
"?????" ?? "???"
28Memory Mapped Files
- A file (or a portion thereof) is mapped into a
contiguous region of the process virtual memory - ????? ??? ???? ???? ?????? ?????????? ?????
??????? - UNIX mmap system call
- Mapping operation is very efficient
- just marking
- ?????? ???? ?"? ????? ???? ?-page table ???????
????? ????? ?? ????? ???? - The access to file is governed by the virtual
memory subsystem
29Memory Mapping
- ????? ????? ????? ??????? (mmap, munmap)
- ????? ?????? ????? ??? ???? ???????.
- ????? - ????? ??????? ??? ??????? ????? page
fault ?????? ???? ?????? ???????
???? fd open(...) lseek(fd, offset,..) read(fd,
buf, len) / use data in buf / lseek(fd,
offset,) write(fd, buf, len)
???? fd open(...) address mmap((caddr_t) 0,
len, (PROT_READ PROT_WRITE), MAP_PRIVATE, fd,
offset) / use data at address /
30Memory Mapping ??? ????
- ???????
- ??? ???? ??????? I/O ?????? - ??? ?? ??????
- ?????? ?? segmentation ???? ????? ???? ?-
segment - ????? ?-buffers (???? buffering ?? ????? ??"?)
- ????? ??????? ??? buffer cache ??????? ????????
- ???? ????? ????? swap ?????
- ???????
- ????? ????? ??????? ?? ???? (??????? ??? ???
"??????" ??????) - ?? ???? ????? ????? ?????? (???? ????? ???)
- ??? ????? ?? ?????? ????? (????? ???? ?????)
- ???? ?????? ?? ????? ????? ??????
31?????? Directories
- ???? ????? ?????? ????? ?????? ???
- ???? ???? ?? ?????
- ?????
- single-level
- ) two level (per user
- tree (dos)
- directed acyclic-graph
- general graph
- Â
- ??? ???? ?? ???? foo ???? /usr/moses/foo
- ????? ??? ????? ????? ( path relative) ?? ?????
????????? (absolute path)
32link/unlink
- Unix ???? ?- links ??????? ???? ???
- link - ????? ????? ?- directory ???? ???? ????
(????? link count) - int link(const char existing, const char new)
- unlink - ???? ????? ?- directory
- ?? reference count 0, ??? ?? ?????
- echo foo gt foo
- ln foo bar/bar
- ls l foo
- -rw-r--r-- 2 user users 4 Jan 8
1232 foo - rm foo
- ls -l bar/bar
- -rw-r--r-- 1 user users 4 Jan 8
1232 bar/bar - ??? ???????/??????? links ?
- ??? ???? ???? mv ?
33 symbolic link
- ???? ????? ????? ????? ?? ???? ???
- int symlink(const char existing, const char
new)
echo foo gt foo ln -s foo bar/bar ls l
foo -rw-r--r-- 1 user users 4 Jan
8 1232 foo rm foo ls -l bar/bar -rw-r--r--
1 user users 4 Jan 8 1232 bar/bar
-gt foo
34??????
- mkdir- ???? ????? ???? (??? ?- dot,dotdot)
- rmdir ???? ????? (????? ?? ?? ????)
- opendir,readdir,closedir (?? system calls) ??????
directories - Â
- chdir
- mount/umount - attach file system
- chroot
main() DIR dirp struct dirent direntp dirp
opendir( "." ) while ( (direntp readdir(
dirp )) ! NULL ) (void)printf( "s\n",
direntp-gtd_name ) (void)closedir( dirp ) return
(0)
35Access Control
- ????? ?????? ????? ??????? ????? ???????
- ???? ????? ?????
- ?? ?? ?????? ????
- ??? ????/????? ???? ????? ??? ???? ???? ??????
????? ???? - ?????, ?????, ????, ?????, ????? ??????
- ????? Access Control List (ACL) ??? ????? ??
??????? ????? ???? ??????? ??? ??? ???
36????? ACL
- ?????? ????? ????? ???? ????? ??? ????? ????
- ?? ????????? ??????? (2000)
- ?? ????? ????? ?????? ??? ftp
- ?? ???? ?????? ????? ????. ???? ????? ??????
- ?????? ? Unix ?? ????? ???? ????????
- user, group, universe
- ??????
- ?? ?????? ???????? ???? ????, ???? Solaris
- -rw-r--r-- idit os . file1.txt
- ? ???? ??? ACL ????
- ????? ?"? setfacl / getfacl
- ????? ????? ??? ???? ?????? .. ??????
37Consistency Semantics
- ???? ?????? ?? ?????? ??? ???? ??????? ???????
???? ??????. - ??? ???????? ???? ???? ?"? ??????? ?????? ?????
?"? ??' ??????? - ????? session ????? ?? ?????? read ?- write
???????? ??? ????? open ?????? - close.
38Unix Consistency Semantics
- ?? ????? ????? ????? ?????? ??? ????????
???????? ???? ???? ???? - ???? ???? ??????? ?????? ????? ????? (?????
file pointer ??? ???????, ???? ?-fork) - ????? ?"? image (????) ???? ??? ???? - ?? ?????
?? read ?- write - ????? ???????? ?? ??????? ??????? ????? ????????
????? ?????? ???? - ????, NFS ????? ????? ????? ??? ??????
- mount ?? ?????? ??????? ?????
- ???????? ? NFS ?? ??????!
- ??????? ?????? ???? ??? ?? ????? (???? ?? 30
?????)
39Session Semantics
- ????? ????? ?? ????? ?????? ??? ????????
???????? ???? ???? ????. - ???????? ?? ?????, ???????? ??????? ????? ??? ?-
sessions ??????? ????? ????. - ???? ?????? ??' images ????? ??? ??-?????
- ????? ???? ?????? AFS
- ????? ????? ??????
- ?????? ??? LAN ? WAN
- caching ?? ?? ???? ???? ??? ?????