CH 2.pdf: Operating System Structures

Document Details

EruditeVorticism1110

Uploaded by EruditeVorticism1110

University of Sharjah

Tags

operating systems computer science OS structures virtualization

Summary

This document discusses operating system services, concepts, and components including system calls, user interfaces like CLI and GUI, resource allocation, protection, and security. It also details differences between various operating system structures, like monolithic and microkernel structures, and concepts of virtualization. The document is focused on computer science concepts related to Operating Systems.

Full Transcript

# CH2 Operating System Structures ## Operating System Services **What is the fundamental role of OS?** To provide an environment for the execution of programs and services to programs and users. **OS services provide functions helpful to the user:** **What are the services that OS provides that...

# CH2 Operating System Structures ## Operating System Services **What is the fundamental role of OS?** To provide an environment for the execution of programs and services to programs and users. **OS services provide functions helpful to the user:** **What are the services that OS provides that can be helpful to the user?** 1. **User Interface:** All OS have a user interface, ex. command line (CLI), Graphics User Interface (GUI), Batch. 2. **Program Execution:** The system must be able to load a program into memory, run it, and end it normally or abnormally (error). 3. **I/O Operations:** A running program may need I/O (either file or I/O device). 4. **File System Manipulation:** Programs need to read, write directories, delete, search, list file information, and permission management. 5. **Communications:** Processes may exchange information either on the same computer or between computers over a network. This can happen by shared memory or message passing (packets). 6. **Error Detection:** The OS needs to be aware of possible errors happening in the CPU, memory hardware, I/O devices, and user programs, each having a different system call parameter passing. The OS must approach them with appropriate action to ensure correct computing. 7. **Debugging Facilities:** Can help users and programmers efficiently use the system. ## OS services provide functions helpful to the system via resource sharing **What are OS services that provide functions helpful to the system?** 1. **Resource Allocation:** When multiple users or jobs are running concurrently, resources must be allocated to each of them. 2. **Types of Resources** can be: * CPU cycles, main memory, file storage, special allocation code. * I/O devices have general request and release code. 3. **Accounting:** To keep track of which users use how much and what kind of computer resources. 4. **Protection and Security:** The owner of information stored in a multi-user system may want to control the use of information, so concurrent processes should not interfere with each other. * **Protection:** All access to the system is controlled. * **Security:** Security of the system from outsiders requires authentication and defending from external I/O devices from invalid access attempts (modification). ## User Operating System Interface (CLI) **What is CLI?** It is a command-line interface that allows direct command entry. The shell fetches the command from the user and executes it. **How can CLI be implemented?** It can be implemented in the kernel or as a system program. ## User Interface Operating System Interface (GUI) **What is GUI?** A user-friendly desktop metaphor interface. **What input devices are used with GUI?** Keyboard, mouse, monitor. Ex. by clicking the mouse, you can open a directory, execute a function, and much more. **What do icons represent in GUI?** Files, programs, actions. **GUI was invented at:** Xerox PARC. **Examples of systems contain both CLI or GUI interfaces:** 1. **Microsoft Windows**: GUI & CLI command shell. 2. **Solaris**: CLI and optional GUI interface (Java Desktop). 3. **Apple Mac OS "Aqua" GUI**: Underneath Unix kernel and shells. ## System Calls **What are system calls?** A programming interface to the services provided by the OS. **What language are system calls written in?** High-level programming language (C, C++). **Example of System Calls** System call sequence to copy the contents of one file to another file. **This example shows:** * The process of copying a file has multiple system calls that depend on each other. * The presence of API hides the complexity of system calls, making programming more efficient and consistent. * The C library takes the program uses API request and in return, it uses the library to execute low-level write and returns output. **What are the **3 general methods used to pass parameters to the OS?** 1. **Simple**: Pass the parameters in registers. Limitation: There may be more parameters than registers. 2. **Storing parameters in a block in memory:** The address of the block is passed as a parameter in a register (Linux, Solaris). 3. **Parameters placed onto the stack by the program and popped by the OS:** There is no limit for parameters. ## Types of System Calls **Examples of Windows and Unix System Calls** *Note: Some are simply user interface, and others are more complex.* **What do system programs provide?** An environment for program development and execution. It defines users. **What are the categories of system programs?** 1. **File Management:** Create, delete, copy, rename, print, dump, list, generally manipulate files and directories. 2. **Status Information:** Date, time, amount of available memory, disk space, number of users, logging programs format and print output to the terminal or output devices, or they may store and retrieve info from the registry. 3. **File Modification:** Text editors to create and modify files, special commands to search the contents of files or perform transformations of the text. 4. **Programming Language Support:** Compilers, assemblers, debuggers, interpreters. 5. **Program Loading and Execution:** Machine language, debugger for high-level language, linkage editors. Absolute loader, relocatable loader, overlay loaders. 6. **Communication:** Mechanism for creating virtual connections among processes, users, and computer systems (ex. send a message to one another, log in remotely, transfer files, browse the web page, send electronic mail messages). ## Operating System Design and Implementation **What factors affect OS design?** 1. Internal structure can vary. 2. The OS needs to have defined goals. 3. Choice of hardware and type of system. 4. Specifications **What are the goals of Operating System?** * **User goals:** OS convenient to use, easy to learn, reliable, safe and fast. * **System goals:** Easy to design, implement, maintain, flexible, reliable, error-free, efficient. **How are system calls accessed by programs?** High-level Application Program Interface (API) rather than direct system call use. Where API invokes the actual system call on behalf of the application programmer. **What is the difference between system calls and API**? * **System call:** Interface to the OS. * **API:** Interface to the system call (ease of programmers). **Note:** User Program -> API -> System calls -> OS services -> Hardware **The 3 most common API:** 1. Win32 API for Windows 2. Unix, Linux, Mac OS 3. Java API for the Java Virtual Machine (JVM) 4. POSIX API for POSIX based systems **Why use API's rather than system calls directly?** 1. Program portability: A program using API can compile and run on any system that supports the same API. 2. Ease of use: Saves the user from the detailed process of system calls. The API does the job. ## Important Principles of OS 1. **Policy:** Decides what will be done. 2. **Mechanism:** Determines how to do something. **Ex:** * Setting a timer for how long is *policy*. * The actual timer is the *mechanism*. **Note:** Separating policy and mechanism adds flexibility. If chained, it would be complex. ## Implementation * **OS Written:** Before low-level language; then language like Algol; Now C, C++. * **The OS Internals:** Lowest level in assembly. * **Main Body in C, System Programs in C, C++, Python using shell scripts.** ## Para Virtualization **What is para virtualization?** It is a way that presents a system that is similar but not identical to hardware for the guest to run. Para virtualization requires the guest OS to be modified. **What is the difference between VM and para virtualization?** * **VM:** The OS is unaware of virtualization and sees a perfect copy of the hardware. No guest OS modification needed. * **Para virtualization:** The OS is aware of virtualization and sees a copy of the hardware, but not identical. It needs the guest OS modification. ## Virtualization Implementation **Why is virtualization difficult to implement?** Because it must provide a duplicate of the hardware (underlying machine). **In what mode does virtualization run and what modes does it create?** * It runs in user mode. * It creates virtual user mode and virtual kernel mode. **What are the advantages and disadvantages of implementing OS in a high-level language?** **Advantages:** * Portability to other hardware * Fast production * Compact code * Easy to understand and debug **Disadvantages:** * Slower execution **Note:** If the hardware is unavailable, the OS can be developed using emulators of the target hardware. ## OS Structures and the Difference between Them | Feature | Simple Structure (MS-DOS) | Monolithic Structure (Traditional Unix) | Layered Structure | Microkernel Structure | |---|---|---|---|---| | Idea | Maximize functionality in minimal space | Integrate all the OS services into a single kernel | Divide the OS into hierarchical layers | Keep the kernel minimal and move services to the user space | | Modularity | No clear Modularity | Limited Modularity | Modularity through layers | High Modularity with user-level services | | Interfaces | Poorly separated interfaces | Interfaces mostly within the Kernel | Interfaces defined between layers | Well defined interfaces between modules | | Kernel size | Small Kernel | Large Kernel with many services | Kernel size depends on layer design | Very small kernel | | Communication | Direct function calls | Direct function calls within Kernel, function calls between layers | Message passing between modules | Message passing | | Advantages | Simple footprint, efficient for limited resources | Simpler initial implementation, easier to design, debug, maintain | Extensible, Portable, reliable, secure | Flexibility, maintainability, scalability | | Disadvantages | Lack of protection, instability, difficult to extend | Difficult to debug and maintain, scalability issues, defining layers can be challenging | Performance overhead, scalability issues | Increased complexity in managing module interactions | | Examples | MS-DOS | Unix (early version), the multiprogramming system | Unix (Loadable modules) | Mach, MINIX, QNX, Solaris, Linux | ## Virtual Machines **What is the idea of virtual machines?** To abstract the hardware of a single computer into several execution environments. **How does a virtual machine relate to the layered approach?** It treats the hardware and the OS kernel as if they were hardware. **What kind of interface does a virtual machine provide?** It provides an interface identical to the underlying bare hardware. **What illusion does the OS host create?** It creates the illusion that a process has its own processor and virtual memory + each guest has a virtual copy of the underlying computer. ## History and Benefits of Virtual Machines **When did the virtual machine first appear?** An IBM mainframe in 1972. **What are the benefits of virtual machines?** 1. Multiple execution environments (different OS) can share some hardware. 2. Protection from each other. 3. Sharing of files can be permitted and controlled. **How can virtual machines communicate?** They can communicate with each other or other physical systems by networking. **What can virtual machines be used for?** * Development * Testing * Consolidation of low-resource systems **Ex:** Virtual Machine format (standard format) allows a VM to run on many virtual machine host platforms. ## Debugging **What is debugging?** Finding and fixing errors or bugs, and performance tuning to optimize system performance. **What does the OS generate that contains error information?** Log files. **What happens when an application fails?** A core dump file, capturing memory of the process. **What happens when the OS fails?** A crash dump file, containing kernel memory. **What is Kernighan's Law about debugging?** Debugging is twice as hard as writing the code. So if you write code as cleverly as possible, you are not smart enough to debug it. **Ex:** Traces is a tool that allows live instrumentation; it fires when code is executed to capture state data and send it to the consumer of the probe. ## Operating System Generation **What must be done to an operating system to run on a specific computer system?** It must be configured or generated for that specific machine. **What is the purpose of the SYSGEN program?** To obtain information concerning the specific configuration of the hardware system and generate the OS for that specific machine. **What type of information does SYSGEN collect?** CPU speed and type, memory available, device interface, etc. ## Booting **What is booting?** Starting a computer by loading the kernel. **What is the bootstrap program and where is it stored?** Code stored in ROM, which is able to locate the kernel, load it into memory, and start executing it. **What is the purpose of the boot block in a two-step boot process?** Loads the bootstrap loader. **What happens when power is initialized?** The execution happens at the fixed memory location. **What is used to hold the initial boot code?** The firmware.

Use Quizgecko on...
Browser
Browser