1 / 20

File Systems and Disk Layout in UNIX

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.

pgreene
Télécharger la présentation

File Systems and Disk Layout in UNIX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Overview • Assignment 11: hints • File systems • Assignment 10: solution • Deadlocks & Scheduling

  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. Disk Layout • A disk contains: • boot block: bootstrap code • super block: state of the file system • inode list: list of file descriptors • data blocks

  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. File Structure datablocks inode

  6. Directories • A directory is a normal file with a list of names and inodes. • Example:

  7. Processes, File Table, … user file descriptor file table inode table

  8. Mounting iso9660 /pictures ext2 /etc /mnt /cdrom /dos /home /proc /usr /var fat \dos \windows ext2 /user1 /user2 /user3 procfs /meminfo /cpu

  9. A11 Ex1 – File size • Calculate the maximum size of a UNIX file on a disk with 2KB data blocks

  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. A11 Ex3 – Redirection • Used for output  input redirects • ./cmd <infile >outfile • ./cmd | grep keyword • Which mechanisms are used? • Which data structures are needed?

  12. A11 Ex4 – Mounting • Which mechanisms are used to support different kinds of file systems? • Hint: different file system structures

  13. Overview • Assignment 11: hints • File systems • Assignment 10: solution • Deadlocks & Scheduling

  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. 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. 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

  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 object’s lock list and put it on the ready list; ELSE mark o as unlocked; END; yield();

  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 object’s wait list; yield();

  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 object’s lock list; yield();

  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 object’s lock list; END; yield();

More Related