Download presentation
Presentation is loading. Please wait.
Published byAlfredo Rubottom Modified over 10 years ago
1
1 Overview Assignment 11: hints File systems Assignment 10: solution Deadlocks & Scheduling
2
2 UNIX Filesystem References: M. Bach, The Design of the UNIX Operating System, Prentice Hall http://lxr.linpro.no/ Each file has a unique inode containing: ownership type access rights size access/creation/… time location of the data on disk
3
3 Disk Layout A disk contains: boot block: bootstrap code super block: state of the file system inode list: list of file descriptors data blocks boot block super block inode listdata blocks
4
4 Inode: Example owner: corti group: inf type: regular file permissions: rwxr-xr-x accessed: Jan 08 2004 1:45 P.M. modified: Jan 08 2004 10:30 A.M. inode: Jan 08 2004 1:45 P.M. disk addresses
5
5 File Structure data blocks inode direct 0 direct 1 direct 2 direct 3 direct 4 direct 5 direct 6 direct 7 direct … direct 11 single indirect double indirect triple indirect
6
6 Directories A directory is a normal file with a list of names and inodes. Example: Inode NumberFile Name 83. 2.. 1798init 1276fsck 85clri 1268motd 1799mount
7
7 Processes, File Table, … 0stdin 1stdout 2stderr 3 4 …… 0stdin 1stdout 2stderr 3 4 …… count 1, rd count 1, rd-wr count 1, rd count 1, wr count 1, rd user file descriptor file table count 3 (/a/b) count 1 (local) count 1 (private) inode table
8
8 Mounting /etc /mnt /cdrom /dos /home /proc /usr /var ext2 \dos \windows fat /pictures iso9660 /user1 /user2 /user3 ext2 /meminfo /cpu procfs
9
9 A11 Ex1 – File size Calculate the maximum size of a UNIX file on a disk with 2KB data blocks
10
10 A11 Ex2 – File access Append one byte at the end of a file Filename./a/b/c/f Size 1G Which sequence of disk accesses is necessary (worst case, no caching)
11
11 A11 Ex3 – Redirection Used for output input redirects./cmd outfile./cmd | grep keyword Which mechanisms are used? Which data structures are needed?
12
12 A11 Ex4 – Mounting Which mechanisms are used to support different kinds of file systems? Hint: different file system structures
13
13 Overview Assignment 11: hints File systems Assignment 10: solution Deadlocks & Scheduling
14
14 A10 Ex1 – Deadlocks Give a real-life example of deadlock. (4) Cars arriving at an intersection at the same time Is it possible to have a deadlock with one process/thread only? Non-reentrant locks
15
15 A10 Ex2 – Synchronization Primitives Assumption: OS with only a yield() system call Pseudo-code implementation of lock, unlock, wait, and notify Data structures: a list of ready threads a flag to mark an object as locked a per-object lock list (list of threads waiting for the lock) a per-object wait list (list of threads waiting for notification)
16
16 lock() If the object (o) is unlocked we lock it, otherwise we move the thread to the lock list. IF o is not locked THEN mark o as locked; ELSE remove the thread from the ready list; insert the thread in the lock list of the object; yield(); END
17
17 unlock() We unlock the object and we move one of the waiting threads to the ready list and call yield(). IF the lock list is not empty THEN remove a thread from the objects lock list and put it on the ready list; ELSE mark o as unlocked; END; yield();
18
18 wait() We have first to unlock the object and then to move the current thread into the wait list. unlock(o); remove the current thread from the ready list; put the current thread in the objects wait list; yield();
19
19 notify() A thread is awakened and must wait for the object to be unlocked. take a thread t from the wait list of o; remove t from the wait list; put t in the objects lock list; yield();
20
20 notifyAll() All the objects are awakened and they must wait for the object to be unlocked. FOR thread t in the wait list of o DO remove t from the wait list; put t in the objects lock list; END; yield();
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.