Unformatted text preview:

Lecture 26OutlineKernel Memory AllocationBuddy System 1Buddy System 2Buddy System 3Slab Allocation 1Slab Allocation 2Slab Allocation 3Slab Allocation 4Slab Allocation 5Storage Systems 1Storage Systems 2File ADT 1File ADT 2File ADT 3File ADT 4File Access Methods 1File Access Methods 2File Access Methods 3Directory ADTDirectory Structures 1Directory Structures 2Directory Structures 3Directory Structures 4Directory Structures 5Friday, March 18 CS 470 Operating Systems - Lecture 26 1Lecture 26Any issues with finding case study references?Questions?Friday, March 18 CS 470 Operating Systems - Lecture 26 2OutlineKernel memory allocationBuddy systemSlab allocationStorage systemsFile ADTFile access methodsDirectory ADTDirectory structuresFriday, March 18 CS 470 Operating Systems - Lecture 26 3Kernel Memory AllocationLast time, briefly discussed whether OS should compete with user processes for free frames. Generally, it does not for the following reasons:Many kernel data structures are less than a page, so the OS must manage its memory usage carefully to minimize waste. Often kernel memory is not handled by the paging system.Due to interaction with hardware devices, kernel memory may need to be physically contiguous.Friday, March 18 CS 470 Operating Systems - Lecture 26 4Buddy SystemAllocation is from a fixed-size segment of physically contiguous pages using a power-of-2 allocator. This allocator satisfies requests in units sized as a power of 2 (4KB, 8KB, 16KB, etc.)For example, suppose original memory segment size is 256KB and there is a request for 21KB. System divides segment into two 128KB segments, call them Aleft and Aright.Friday, March 18 CS 470 Operating Systems - Lecture 26 5Buddy SystemAleft is further divided into 64KB segments Bleft and Bright, then Bleft is divided into 32KB segments Cleft and Cright. Cleft is used to fulfill the 21KB request.Original 256KB segmentAleft - 128KB Aright - 128KBBleft - 64KB Bright - 64KBCleft - 32KBCright - 32KBFriday, March 18 CS 470 Operating Systems - Lecture 26 6Buddy SystemAdvantage of this system is that adjacent buddies can be combined quickly to form larger segments using coalescing. For example, when the kernel releases Cleft, it can be combined with Cright, then Bright, then Aright to recover the original 256KB segment.Disadvantage is that can have lots of internal fragmentation due to the coarse segment sizes.Original Linux kernel used this allocator.Friday, March 18 CS 470 Operating Systems - Lecture 26 7Slab AllocationDefine a slab as 1 or more physically contiguous pages. Define a cache connected with 1 or more slabs. Each cache holds objects of a unique kernel data structure type (e.g. process descriptor, file objects, semaphores, etc.) usually based on size. Kernel objects are instantiated (i.e., pre-allocated) in the caches and initially marked as free. As objects are allocated, the cache entries are marked as used.Friday, March 18 CS 470 Operating Systems - Lecture 26 8Slab AllocationFriday, March 18 CS 470 Operating Systems - Lecture 26 9Slab AllocationThe number objects stored in a cache depends on the size of the slab (and the size of the objects in the cache).A particular slab may be:full - all objects in the slab are marked as usedempty - all objects in the slab are marked as freepartial - slab contains both used and free objectsFriday, March 18 CS 470 Operating Systems - Lecture 26 10Slab AllocationAllocation requests are fulfilled using (in order):free object in a partial slabfree object in an empty slabfree object in a newly created slab that is also assigned to a cacheAdvantagesNo wasted memory due to fragmentation. Objects in each cache are exactly the correct size.Fast allocation, especially when objects are allocated and deallocated frequently.Friday, March 18 CS 470 Operating Systems - Lecture 26 11Slab AllocationSlab allocation first appeared in the Solaris 2.4 kernel. Now also used in the Linux kernel, and for certain types of user-mode requests.This ends the section on memory management. The next section is on storage systems.Friday, March 18 CS 470 Operating Systems - Lecture 26 12Storage SystemsStorage systems logically are three partsUser/programmer API - Chapter 10OS implementation of API - Chapter 11Actual disk structures - Chapter 12File system is a logical view of information storage. The logical storage unit is a file mapped to a physical device. For most "normal" applications, it is the smallest unit of information. I.e., must have a file to write to a "disk".Friday, March 18 CS 470 Operating Systems - Lecture 26 13Storage SystemsFiles are general. View them as containers of bits, bytes, lines, or records. A file's format is defined by its creator.Files are organized into directories. Both can be view as abstract data types (ADTs).Friday, March 18 CS 470 Operating Systems - Lecture 26 14File ADTLike all ADTs, can discuss a file object's attributes and its operations.What might be the attributes of a file object?Friday, March 18 CS 470 Operating Systems - Lecture 26 15File ADTWhat might be a file object's operations?Friday, March 18 CS 470 Operating Systems - Lecture 26 16File ADTMany operations need to search a directory, so most OS's require an open( ) operation. This operation finds its file name argument in a directory and enters it into an open file table (OFT).For multi-user OS's, the OFT is usually 2-levelGlobal system OFT for all open files, keeps track of location, permissions, size, open count, locksProcess local OFT, keeps track access rights (e.g., open for read-only, etc.)In UNIX, file descriptor is index into local OFTFriday, March 18 CS 470 Operating Systems - Lecture 26 17File ADTSome OS's have memory-mapped files. Disk pages are loaded into physical memory frames. Processes map VM pages to these frames. Writes to these pages become writes to a file, which are saved when the file is unmapped (i.e., closed).Friday, March 18 CS 470 Operating Systems - Lecture 26 18File Access MethodsData in files are access using an access method. Access methods often depend on the hardware the data are stored on.Sequential access allows access to one logical data unit at a time (e.g., byte, record). After each read/write operation, there is automatic advancement of a current position pointer. E.g., C++ streams are


View Full Document
Download Lecture 26
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 26 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 26 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?