Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCC69: Operating Systems Tutorial 10. Hints on testing Assignment 3 How to test tlb replacement algorithms? – Write a program that creates an array larger.

Similar presentations


Presentation on theme: "CSCC69: Operating Systems Tutorial 10. Hints on testing Assignment 3 How to test tlb replacement algorithms? – Write a program that creates an array larger."— Presentation transcript:

1 CSCC69: Operating Systems Tutorial 10

2 Hints on testing Assignment 3 How to test tlb replacement algorithms? – Write a program that creates an array larger than the TLB footprint, but hopefully smaller than memory. – It should first touch each page of the array once, which should cause each page to be loaded into memory. – Then it should touch the pages sequentially in a tight loop The goal is to force the TLB to be filled quickly, so that TLB replacements will be necessary. – If this generates "out of memory" errors, you will need to increase the memory size of the machine (in sys161.conf) to run this test. Test your sequential replacement algorithm first.

3

4 Assignment Review Implement the file-related system calls – open, close, dup2 – read, write, lseek – chdir, getcwd – Fstat, getdirentry Implement getdirentry for SFS TODAY: review existing file system design

5 Virtual File System Concept Provides an abstract file system interface – Allows higher-level system code to manage a “file” abstraction in a uniform manner, independent of the implementation details of a specific type of file system – Standard system calls such as open, read, write, etc. can be implemented in terms of operations on the abstract file system, rather than having a separate implementation for each real file system – Abstraction layer is for the OS itself It does not provide any additional convenience to the user- level programmer who interacts with the file systems through the system calls

6 Schematic View of VFS

7 VFS Design in OS161 VFS layer is essentially an object-oriented design. Basic objects are: – file systems (defined in kern/include/fs.h) – vnodes (defined in kern/include/vnode.h) – vnode is an abstract representation of a file.

8 Basic objects of VFS Start with the file system objects (fs) – abstract definition of a file system consists of pointers to functions that implement standard operations (sync, getvolname, getroot, and unmount) a pointer to file-system specific data. – A struct vnode is an abstract representation of a file. It is an interface in the Java sense that allows the kernel’s file system-independent code to interact usefully with multiple sets of file system code.

9 Abstract File System Structure struct fs { // flush all dirty buffers to disk int (*fs_sync)(struct fs *); // Return volume name of file system const char *(*fs_getvolname)(struct fs *); // Return root vnode of file system struct vnode *(*fs_getroot)(struct fs *); // Attempt unmount of file system int (*fs_unmount)(struct fs *); // Pointer to file-system specific data void *fs_data; };

10 Abstract operations on a vnode vop_read vop_getdirentry vop_write vop_stat vop_gettype …

11 Implementing a File System An implementation of a specific file system type must provide implementations of functions in abstract file system struct, as well as a “mount” function that can be passed to the abstract vfs_mount routine. The file-system specific mount function must create and initialize an abstract fs structure with pointers to the actual functions implementing the abstract ones. It must also perform any file-system specific initialization that is needed, and fill in the fs_data pointer

12 Assignment 3 Your primary goals are to complete a set of file-system related system calls and to augment SFS with the ability to read directory entries. – open, close, … – write, getdirentry, … A file descriptor is an indexfor an entry in a kernel-resident data structure containing the details of all open files.

13 SFS Implementation See kern/fs/sfs/sfs_fs.c for file system level operations sfs_mount is called from higher-level code to mount sfs (i.e., from the menu) – Calls abstract mount function, vfs_mount, passing a pointer to the sfs-specific mount function, sfs_domount Allows VFS layer to control synchronization if multiple mount commands happen simultaneously

14 Mount The way mount works is that you call vfs_mount and pass it a file system-specific mount routine. This routine takes a device and hands back a pointer to an abstract file system.

15 Sfs_domount Initializes an sfs_fs structure(sfs-specific data structure) by reading file system superblock and free space bitmap off disk Initializes abstract file system structure with appropriate function pointers, and sets the fs_data to point to the full sfs_fs structure Returns pointer to abstract fs to VFSlayer Thus, from the abstract file system structure, we can locate the SFS functions that implement basic file system operations, and we can locate the full sfs_fs structure which provides information that those functions will need to do their work.

16 Relation of sfs_fs to fs structs VFS layer keeps list of “known devices” with a pointer to the abstract file system mounted on each device (if any)

17 Vnode A vnode is an abstract in-memory representation of a file Mainly provides pointers to code and data for a specific implementation Most importantly, the vnode contains: – A pointer to the abstract file system structure for the file system that stores the file represented by the vnode – A table of function pointers (vn_ops) to the routines that actually implement the standard operations on files for the specific type of file system Operations on files must thus first locate the vnode for the file, and then invoke the requested action by calling a function in the vn_ops table

18 Vnode in OS161

19 A4 Hints Open file tables - things need to be tracked both globally and per process – vnode ref count? – Open vnodes a process owns? Read/writeposition? – What happens when process forks?

20 sys_open We’ll rely on vfs_open to do most of the work. But before that, we need to check: – Is filename a valid pointer? (alignment, NULL, kernel pointer, etc.) – Is flags valid? flags can only contain exactly one of O_RDONLY, O_WRONLY and O_RDWR After these, we need to allocate a fd to the opened file: just scan the curthread->t_fdtable and find a available slot (NULL). Then we need to actually open the file using vfs_open. Once vfs_open successfully returns, we can initialize a struct fdesc.


Download ppt "CSCC69: Operating Systems Tutorial 10. Hints on testing Assignment 3 How to test tlb replacement algorithms? – Write a program that creates an array larger."

Similar presentations


Ads by Google