200 likes | 211 Views
This assignment explores the concepts of file systems, disk layout, and mounting in UNIX. Topics include inode structure, file sizes, file access, redirection, and support for different file systems.
E N D
Overview • Assignment 11: hints • File systems • Assignment 10: solution • Deadlocks & Scheduling
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
Disk Layout • A disk contains: • boot block: bootstrap code • super block: state of the file system • inode list: list of file descriptors • data blocks
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
File Structure datablocks inode
Directories • A directory is a normal file with a list of names and inodes. • Example:
Processes, File Table, … user file descriptor file table inode table
Mounting iso9660 /pictures ext2 /etc /mnt /cdrom /dos /home /proc /usr /var fat \dos \windows ext2 /user1 /user2 /user3 procfs /meminfo /cpu
A11 Ex1 – File size • Calculate the maximum size of a UNIX file on a disk with 2KB data blocks
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)
A11 Ex3 – Redirection • Used for output input redirects • ./cmd <infile >outfile • ./cmd | grep keyword • Which mechanisms are used? • Which data structures are needed?
A11 Ex4 – Mounting • Which mechanisms are used to support different kinds of file systems? • Hint: different file system structures
Overview • Assignment 11: hints • File systems • Assignment 10: solution • Deadlocks & Scheduling
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
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)
lock() If the object (o) is unlocked we lock it, otherwise we move the thread to the lock list. IFo 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
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 object’s lock list and put it on the ready list; ELSE mark o as unlocked; END; yield();
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 object’s wait list; yield();
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 object’s lock list; yield();
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 object’s lock list; END; yield();