100 likes | 123 Views
Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY. URL: http://kovan.ceng.metu.edu.tr/~erol/Courses/CENG334. Operating System Design and Implementation Topics OS structures. CENG334 Introduction to Operating Systems.
E N D
Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL: http://kovan.ceng.metu.edu.tr/~erol/Courses/CENG334 Operating System Design and Implementation Topics • OS structures CENG334Introduction to Operating Systems Some of the following slides are adapted from Matt Welsh, Harvard Univ.
OS design and implementation • There is no ultimate OS that would satisfy all requirements: • Trade-offs have to made at each level and for all aspects. • Important principle to separate • Policy: What will be done? • Mechanism: How to do it? • Mechanisms determine how to do something, policies decide what will be done • The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later
Operating Systems Structure(What is the organizational Principle?) • Simple • Only one or two levels of code • Layered • Lower levels independent of upper levels • Microkernel • OS built from many user-level processes • Modular • Core kernel with Dynamically loadable modules
Simple Structure • MS-DOS – written to provide the most functionality in the least space • Not divided into modules • Interfaces and levels of functionality not well separated
Monolithic Kernels • Most common OS kernel design (used in UNIX and Linux) • Kernel code is privileged and lives in its own address space • User applications are unprivileged and live in their own separate address spaces • All kernel functions loaded into memory as one large, messy program • Pros and cons??? User application User application User application System call Protection boundary Kernel Memory management Process management Filesystem TCP/IP stack Accounting CPU support Device drivers Disk I/O
Monolithic Kernels • Most common OS kernel design • Kernel code is privileged and lives in its own address space • User applications are unprivileged and live in their own separate address spaces • All kernel functions loaded into memory as one large, messy program • Pros and cons • Pro: Overhead of module interactions within the kernel is low (function call) • Pro: Kernel modules can directly share memory • Con: Very complicated and difficult to organize • Con: A bug in any part of the kernel can crash the whole system! User application User application User application System call Protection boundary Kernel Memory management Process management Filesystem TCP/IP stack Accounting CPU support Device drivers Disk I/O
Layered kernels • Operating system is divided many layers (levels) • Each built on top of lower layers • Bottom layer (layer 0) is hardware • Highest layer (layer N) is the user interface • Each layer uses functions (operations) and services of only lower-level layers • Advantage: modularity Easier debugging/Maintenance • Not always possible: Does process scheduler lie above or below virtual memory layer? • Need to reschedule processor while waiting for paging • May need to page in information about tasks • Important: Machine-dependent vs independent layers • Easier migration between platforms • Easier evolution of hardware platform
User application User application User application Memory management Process management Filesystem TCP/IP stack Accounting CPU support Device drivers Disk I/O Microkernel Microkernels • Use a very small, minimal kernel, and implement all other functionality as user level “servers” • Kernel only knows how to perform lowest-level hardware operations • Device drivers, filesystems, virtual memory, etc. all implemented on top • Use inter-process procedure call (IPC) to communicate between applications and servers • Pros and Cons??? Inter-process procedure call Protection boundary
Microkernels - 2 • Pros and cons • Pro: Kernel is small and simple, servers are protected from each other • Con: Overhead of invoking servers may be very high • e.g., A user process accessing a file may require inter-process communication through 2 or 3 servers! • Microkernels today • Lots of research in late 80's and early 90's • Windows NT uses “modified microkernel”: • Monolithic kernel for most things, OS APIs (DOS, Win3.1, Win32, POSIX) implemented as user-level services • Mac OS X has reincarnated the microkernel architecture as well: • Gnarly hybrid of Mach (microkernel) and FreeBSD (monolithic)
Modules-based Structure • Most modern operating systems implement modules • Uses object-oriented approach • Each core component is separate • Each talks to the others over known interfaces • Each is loadable as needed within the kernel • Overall, similar to layers but more flexible