博文

目前显示的是 十二月, 2016的博文

[OSC] Day7: File System

图片
File System File System1 Construction of a hard disk Low level format Disks are organized in Cylinders: a collection of tracks in the same relative position to the spindle Tracks: a concentric circle on a single platter side Sectors: segments of a track(usually 512B or 4KB in size) Sectors usually have an equal number of bytes in them, consisting of a preamble, data, and an error correcting code cylinder skew Disks usually have a cylinder skew: i.e., an offset is added to sector 0 in adjecent tracks to account for the seek time Consecutive disks sectors may be interleaved to account for transfer time Disk Access Time Access time = seek time + rotational delay + transfer time Seek time = time needed to move the arm to the cylinder (dominant) Rotational latency = time before the sector appears under the head (on average half the rotation time) Transfer time = time to transfer the data The estimated seek time (i.e., to move the arm from one track to ano

[OSC] Day6: Paging, Virtual Memory and page replacement

图片
Memory Management Paging A page is a small block of contiguous memory in the logical address space, i.e. as seen by the process A frame is a small contiguous block in physical memory Pages and frames(usually) have the same size: This is usually power of 2 Sizes range between 512 bytes and 1Gb Relocation Logical address ( page number, offset within page ) needs to be translated into a physical address ( frame number, offset within frame ) Multiple “base registers” will be required: Each logical page needs a separate “base register” that specifies the start of the associated frame page table The base registers are stored in the page table The page table can be seen as a function, that maps the page number of the logical address onto the frame number of the physical address, frameNumber = f(pageNumber) Every process has its own page table containing its own “base registers” Address translation A logical (physical) address is relative to the start of the pro

[OSC] Day5: Memory Management (Non-contiguous memory management part)

图片
Memory Management Because the content is too much, we’ll divide it into 6 parts. Memory Management 1 OS responsibility Allocate/deallocate memory when requested by processes, keep track of used/unused memory Distribute memory between processes and simulate an “infinitely large” memory space Control access when multiprogramming is applied Transparently move data from memory to disk and vice versa Models(Contiguous & Non-contiguous) Contiguous memory management models allocate memory in one single block without any holes or gaps Non-contiguous memory management models are capable of allocating memory in multiple blocks, or segments, which may be placed anywhere in physical memory (i.e., not necessarily next to each other) Partitioning Mono-programming: one single partition for user processes No memory abstraction Only one single user process is in memory/executed at any point in time (no multi-programming) A fixed region of memory is allocated to the OS/ke

[OSC] Day4: Deadlocks

图片
Deadlock Deadlocks and conditions for deadlocks How do they occur? Process A and B request the resources in opposite orders and end up in deadlock Deadlock can occur on the same machine or between multiple machines (e.g. resources are requested over the network) and any number of resources Deadlocks are not just related to operating systems but also occur in databases A resource (e.g. a device, a data record, file, semaphore) can be acquired, used, and released A resource can be preemptable , i.e. it can be forcefully taken away from the process without permanent adverse effect(e.g. memory -> disk) A resource can be non-preemptable , i.e. it cannot b taken away from a process without permanent adverse effect(e.g. CD, printer) If a non-preemptable resource is requested but not available, the process is made to wait Deadlocks only occur for non-preemtable resources since preemtable resources can be temporarily taken away to recover from the deadlock definition