Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Course Outline Processes & Threads CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Networks, Protection and Security.

Similar presentations


Presentation on theme: "1 Course Outline Processes & Threads CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Networks, Protection and Security."— Presentation transcript:

1 1 Course Outline Processes & Threads CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Networks, Protection and Security

2 2 Files: OS Abstraction Files: another OS-provided abstraction over hardware resources OS AbstractionHardware Resource Processes Threads CPU Address spaceMemory FilesDisk

3 3 File System Abstraction Device-independent interface open(), close(), link(), read(), write(), rename() Device-level interface Manage disk in terms of sectors, tracks, & blocks seek(), readblock(), writeblock() OS converts these to operations on raw hardware (disk)

4 4 User Expectations on Data Persistence Data lives across jobs, power outages, crashes Speed Quick access to data Size Ability to store lots of data Sharing/protection Users can share or restrict access to data when appropriate Ease of use User can easily find, examine & modify data

5 5 Hardware/OS Support for Data Persistence: disks: non-volatile memory Speed: random/quick access devices Size: disk capacity growing fast Persistence: redundancy & fault-tolerance Sharing/protection: UNIX privileges Ease of use: Names associated with data (files) Hierarchical directories Transparent mapping of devices hardware operating system

6 6 Files Named collection of related information recorded on secondary storage Logical unit of storage on a device Can contain programs (source, binary) or data e.g., helloworld.cpp, resume.doc Can be structured or unstructured IBM mainframe OS: series of records (structured) UNIX: file = stream of bytes (unstructured) Files have attributes: name, type, location, size, protection, creation time...

7 7 User Interface to File System Data operations: create(), delete() open(), close() read(), write(), seek() Naming operations: get & set attributes (ownership, protection) hard link, soft links, rename

8 8 OS File-Related Data Structures Open file table – shared by all processes with open file open count file attributes (ownership, protection, etc.) location(s) of file on disk pointers to location(s) of file in memory Per-process file table – one for each file Pointer to entry in open file table Current position in file (offset) Mode in which process accesses file (r, w, r/w...) Pointers to file buffer

9 9 File Operations: Opening Files fd = open(name, mode) Check if file is already open by another process If not: Find file Copy file descriptor into system-wide open file table Check protection of file against requested mode If not OK, abort Increment open count Create entry in process’s file table pointing to entry in system-wide table Initialize current file pointer to start of file

10 10 File Operations: Closing Files close (fd) Remove entry for file in process’s file table Decrement open count in system-wide file table If open count == 0: Remove entry from system-wide file table

11 11 File Operations: Reading File Random access: read(fd, from, size, buf) OS reads “size” bytes from file position “from” into “buf” for (i = from; i < from + size; i++) buf[i – from] = file[i]; Sequential access: read(fd, size, buf) OS reads “size” bytes from current file position “from” into “buf”; increments file position for (i = 0; i < size; i++) buf[i] = file[fp + i]; fp += size;

12 12 Other File Operations write Similar to read, but copies from buffer to file seek Just updates fp memory mapping file map portion of virtual address space to file read/writes to that memory = OS reads/writes from corresponding location in file avoids need for explicit reads/writes

13 13 File Access Methods Common file access patterns from programmer’s perspective Sequential: data processed in order Most programs use this method Example: compiler reading source file Keyed: address block based on key table Example: database search, hash table, dictionary Common file access patterns from OS perspective Sequential: pointer to next byte; update on read/write Random: address any block directly given offset in file

14 14 Naming & Directories Need method of retrieving files from disk! OS uses numbers (inodes) for files People prefer names... OS provides directory to map names to file descriptors

15 15 Structure of Directories One level directory One namespace for entire disk, every name unique Directory contains (name, index) pairs Used by Apple, CP/M, DOS 1.0, first MacOS Two level directories Separate directories for each user Tree-structured directories Used by all modern operating systems Allows user to create their own subdirectories

16 16 Directory Operations Search for file: locate entry Create file: adds directory listing Delete file: removes directory listing List directory: list all files (ls) Traverse file system

17 17 Referential Naming Hard links (UNIX: ln command) Allows multiple links to single file Example: “ln A B”: initially: A -> file # 100 after: A, B -> file # 100 OS maintains reference counts Deletes file only after last link to it is deleted

18 18 Referential Naming Soft (symbolic) links (UNIX: ln -s) Makes symbolic pointer from one file to another “ln -s A B”: Initially, A -> file #100 After, A -> file #100, B -> A Removing B does not affect A Removing A: dangling pointer Problem: Circular links can cause infinite loops E.g., list all files in directory & its subdirectories

19 19 Protection OS must allow users to control access to files Grant or deny access to file operations depending on protection information Access lists and groups (Windows) Access list for each file with user name and access type Lists can become large & tedious to maintain Access control bits (UNIX) Three categories of user (owner, group, world) Three types of access privileges (read, write, execute) One bit per operation (111101000 = rwxr-x----)

20 20 Summary File systems provide Naming Protection Persistence Fast access Next time: file system implementation


Download ppt "1 Course Outline Processes & Threads CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Networks, Protection and Security."

Similar presentations


Ads by Google