1 / 19

Operating System Functions Overview - Lecture 3

Learn about OS process, memory, disk, file management, protection, and system design approaches including monolithic kernel, microkernel, and virtual machine. Understand dual-mode operation, system calls, and API interactions.

kristenl
Download Presentation

Operating System Functions Overview - Lecture 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 3: OS Functions and Design Approaches • OS duties • process management • memory management • disk/file management • protection & security • interaction with OS • dual-mode operation • system calls • API, system programs, UI • OS design approaches: • monolithic kernel • microkernel • virtual machine

  2. Process Management • OS manages many kinds of activities: • user programs • system programs: printer spoolers, name servers, file servers, etc. • a running program is called a process • a process includes the complete execution context (code, data, PC, registers, OS resources in use, etc.) • a process is not a program • program - a sequence of instructions (passive) • process - one instance of a program in execution (active); • many processes can be running the same program and one program may cause to create multiple processes • from OS viewpoint process is a unit of work; OS must: • create, delete, suspend, resume, and schedule processes • support inter-process communication and synchronization, handle deadlocks

  3. Memory Management • primary (main) memory (RAM) • provides direct access storage for CPU • processes must be in main memory to execute • OS must: • mechanics • keep track of memory in use • keep track of unused (“free”) memory • protect memory space • allocate, deallocate space for processes • swap processes: memory  disk • policies • decide when to load each process into memory • decide how much memory space to allocate to each process • decide when a process should be removed from memory

  4. Disk Management • the size of the disk is much greater than main memory and, unlike main memory, disk is persistent (survives system failures and power outages) • OS hides peculiarities of disk usage by managing disk space at low level: • keeps track of used spaces • keeps track of unused (free) space • keeps track of “bad blocks” • OS handles low-level disk functions, such as: • schedules of disk operations • and head movement

  5. File Management • disks provide long-term storage, but are awkward to use directly • file - a logical named persistent collection of data maintained by OS • file system - a logical structure that that is maintained by OS to simplify file manipulation; usually directory based • OS must: • create and delete files and directories • manipulate files and directories - read, write, extend, rename, copy, protect • provide general higher-level services - backups, accounting, quotas • note the difference between disk management and file system management

  6. Protection & Security • protection – any mechanism for controlling access of processes or users to resources • disk, memory, CPU, • security – defense of the system against internal and external attacks • systems generally first distinguish among users, to determine who can do what • user identities and privileges associated with this identifier • user ID then associated with all files, processes of that user to determine access control

  7. Dual-Mode Operation • to allow protection OS operates in dual-mode • user mode and kernel mode • mode bit provided by hardware • user (1), kernel (0) • enables OS to distinguish when system is running user code or kernel code • some instructions designated as privileged, only executable in kernel mode • changing modes • modifying timers • modifying interrupt service routines • I/O device access

  8. System Call Definition • app. program can ask the OS to carry out service forit by invoking a system call • to the application the invocation is similar to an ordinary function call • example: Unix write system call description prompt% man -S 2 write WRITE(2) Linux Programmer's Manual WRITE(2) NAME write - write to a file descriptor SYNOPSIS #include <unistd.h> ssize_t write(int fd, const void *buf, size_t count); DESCRIPTION write() writes up to count bytes to the file referenced by the file descriptor fd from the buffer starting at buf. … RETURN VALUE On success, the number of bytes written are returned …

  9. Mode Switch • mode switch – transition from user to kernel mode • system call generates a trap (software generatedinterrupt) • physical interrupt occurs (e.g. a timer interrupt) • control is transferred to the interrupt service routine, which may pass control to the OS (in kernel mode) return it back to the user process • in case OS needs to do extensive work, it needs to save the context (state) of the user program

  10. Function Invocation TraceAcross Modes • Example function invocation in Solaris (Unix-like OS from Sun Microsystems) • node the mode (User or Kernel) for function invocation

  11. System Call Example • a typical app. program invokes system calls repeatedly • example: copying a file

  12. Application Program Interface • “raw” system calls tend to be difficult to use • application program interface (API) defines functions that are more convenient to use • API functions • can be invoked by app. programmer • run in user mode • directly invoke system calls • implemented in system libraries that come with the OS and are linked to the app. program • API examples: POSIX API (implemented by most Unix systems, MacOS X), Java API, Win 32 API – windows • ex: printf (C function that prints formatted output, part of POSIX API) repeatedly invokes write

  13. System Programs and UIs • system programs come with the OS • they are designed for end users – the personfor whom the computer/OS/app. programs are designed • cf. application programmers, OS programmers • operate in user mode • typical tasks: file manipulation, status info, file modification (editors), programming language support (compilers/assemblers), configuration, communication, etc. • user interface (UI) is a way the end-user interacts with system programs (and through them with the OS), • command-line interface (CLI) – interaction through command interpreter (shell) – a text-based system program • graphical-user interface (GUI) – mouse-heavy with a lot of graphics • most popular OSes support both kinds of UI

  14. app. processes usermode system processes user processes systemcalls kernel machine- signals files CPU scheduling kernelmode terminals swapping page replacement independent character I/O disk, tape virtual memory machine- terminal device memory drivers drivers drivers dependent commands/interrupts hardware device controllers Monolithic Kernel OS Design • advantages: speed and ease of operation (everything is at hand) • disadvantages: • hard to develop, maintain, modify and debug • kernel gets bigger as the OS develops critical OS data structures and device registers are protected from user programs

  15. Modular Kernel • classic monolithic kernel requires all functionality to beinbuilt into kernel and loaded at boot-time – waste of RAM, limited flexibility • loadable kernel module – object file to be loaded at boot time or, possibly compile time • extends base kernel functionality, common functions of kernel modules • device drivers/bus drivers, filesystems, system calls, CPU scheduling classes, executable file formats • loaded to kernel address space has full access to all kernel memory • has defined programming interface, possibly protected • Linuxes, Windows, Solaris, Mac OS X support kernel modules

  16. system processes user processes user mode thread file CPU system system scheduling commands/interrupts hardware network paging support kernelmode micro-kernel communication protection low-level VM processor control device controllers Microkernel • advantages: reliability, ease of development, modularity - parts can be replaced and tailored to the architecture, user requirements etc. • disadvantages: slow? • examples: MacOS X, Windows XP • small kernel implements communication (usually messages) • when system services are required microkernell calls other parts of OS running in user modes and passes the request there

  17. Virtual Machine • OS’s system callsare considered an enhancement ofhardware’sinstruction set • extend further –virtual machine • each user task isprovided with an abstract (virtual machine) which OS + hardware implement • IBM – pioneered • modern examples: • Java VM – next slide • VMware Player – extra guest/host bit, guest OS executes limited set of instructions, if different instruction – trap to host OS adv. – portability at binary-level, security, greater language flexibility dis. – speed(?)

  18. Java Virtual Machine (JVM) • Java source code is translated into an architectureindependent java bytecode • bytecode is executed by JVM • JVM can be implemented purely in software or in hardware • JVM verifies bytecode’s correctness and then either interprets (translates the code into machines instructions one by one) • or just-in-time (JIT) compiles to optimize, or both adv. – portability at binary-level, security, greater language flexibility dis. – speed(?)

  19. Lecture Review • major OS duties are • process management • memory management • disk/file management • OS interacts with users through system calls, to ease interaction • API - for app. programmers • GUI or CLI for end-users • OS is a big and complex program; traditional monolithic kernel design approach yields OSes that are fast but hard to develop, modify and debug; other approaches have been suggested: • microkernel • virtual machine

More Related