CS330 · Annotated SlidesChapter 2 — Operating System Services and Structures
Chapter 2 · Annotated slides

Operating System Services and Structures

OS services, command-line, GUI and touch interfaces, system calls and APIs (POSIX, Win32, Java), parameter passing, types of system calls, and OS structures: monolithic, layered, microkernel, modules and hybrid systems.

Slide text Study notes Highlight: key words Tips, tricks & traps Seen again elsewhere How it can come up
Slide 1: Slide 1
Exam weight Low

    Outline of this lecture

    In this lecture, we will cover the following:

    • Operating System Services
    • User Operating System Interface
    • System Calls
    • Types of System Calls
    • System Programs
    • Operating System Design and Implementation
    • Operating System Structure
    • Operating System Debugging
    • Operating System Generation
    • System Boot
    2
    Exam weight Low

      Objectives

      To describe the services an operating system provides to users, processes, and other systems

      To discuss the various ways of structuring an operating system

       To explain how operating systems are installed and customized

      and how they boot

      3
      Exam weight Low

        Operating System Services

        OS provides an environment for execution of programs and services to programs and users. One set of OS services provides functions that are helpful to the user:

        • User Interface- - Almost all operating systems have a user interface (). Varies UI between Command-Line (CLI) , Graphics User Interface (GUI)
        • Program execution – system capability to load a program into memory and to run it. OS able to end a program ’ s execution either normally or abnormally.
        • I/O operations – since user programs cannot execute I/O operations directly, the operating system must provide some means to perform I/O.
        • File-system manipulation – The OS gives the ability to read, write, create, open, close and delete files / directories.
        • Error detection – ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs.
        • Communications – exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing (packets moved by the OS, see chapter 3).
        4
        Exam weight Low
        1. Services for the user: UI, program execution, I/O, file-system manipulation, communication, error detection.

        Additional Operating System Functions

        Additional functions exist not for helping the user, but rather for ensuring efficient system operations of the system itself via resource sharing.

        • Resource allocation – allocating resources to multiple users or multiple jobs running concurrently, resources must be allocated to each of them.
        • Accounting – keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics.
        • Protection & Security – The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other Protection involves ensuring that all access to system resources is controlled  Security of the system from outsiders requires user authentication, extends to  defending external I/O devices from invalid access attempts If a system is to be protected and secure, precautions must be instituted  throughout it. A chain is only as strong as its weakest link.
        5
        Exam weight Low
        1. Services for the system itself: resource allocation, accounting (logging), protection and security.
        Slide 6: A View of Operating System Services
        Exam weight Low

          User Operating System Interface - CLI

           CLI or command interpreter allows direct

          command entry

          Sometimes implemented in kernel, sometimes by systems

          program On systems with multiple CLI to choose from, the

          interpreters are known – shells Primarily fetches a command from user and executes it

          Sometimes commands built-in, sometimes just names of

          programs

          If the latter, adding new features doesn ’ t require shell

          modification

          7
          Exam weight Low
          1. CLI (command interpreter / shell) reads and runs commands; GUI uses windows and a mouse; touch interfaces use gestures.
          Slide 8: Bourne Shell Command Interpreter-
          Exam weight Low

            User Operating System Interface - GUI

            User-friendly desktop metaphor interface

            Usually mouse, keyboard, and monitor Icons represent files, programs, actions, etc

            Various mouse buttons over objects in the interface cause various actions

            (provide information, options, execute function, open directory (known as a folder)

            Invented at Xerox PARC in the early 1970s

            Many systems now include both CLI and GUI interfaces

            Microsoft Windows is GUI with CLI

            “ command shell

            ”

            Apple Mac OS X is

            “ Aqua GUI interface with UNIX kernel underneath

            ”

            and shells available Unix and Linux have CLI with optional GUI interfaces (CDE, KDE,

            GNOME)

            9
            Exam weight Low
              Slide 10: Touchscreen Interfaces
              Exam weight Low
                Slide 11: The Mac OS X GUI
                Exam weight Low
                  ★ Past exam

                  System Calls

                  • System calls provide the interface between a running program and O/S.
                  • Typically written in a high-level language (C or C++)
                  • Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use
                  • Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM) (Note that the system-call names used throughout this text are generic)
                  12
                  Exam weight High
                  1. System calls are the programming interface to OS services; programs usually reach them through an API (Win32, POSIX, Java API).
                  Exam trapThe JVM is not a system-call API; the Java API is.
                  🎯 How this can come up · 2 questions
                  MCQ

                  The API that Unix-like systems give programmers is:

                  MCQ

                  The three most common APIs for system calls include all EXCEPT:

                  System Call Implementation

                   Typically, a number associated with each system call

                  System-call interface maintains a table indexed according to these numbers

                   The system call interface invokes intended system call in OS kernel and

                  returns status of the system call and any return values

                   The caller needs know nothing about how the system call is implemented

                  Just needs to obey API and understand what OS will do as a result call

                  Most details of OS interface hidden from programmer by API

                  Managed by run-time support library (set of functions built into

                  libraries included with

                  compiler)

                  13
                  Exam weight Low
                    Slide 14: API – System Call – OS Relationship
                    Exam weight Low
                    1. The system-call interface uses a table indexed by system-call number; the caller doesn’t need to know how it is implemented.

                    System Call Parameter Passing

                    Often, more information is required than simply identity of desired system call

                    Exact type and amount of information vary according to OS and call

                     Three general methods used to pass parameters to the OS

                    Simplest: pass the parameters in registers

                    In some cases, may be more parameters than registers

                    Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register

                    This approach taken by Linux and Solaris

                     Parameters placed, or pushed, onto the stack by the program and popped

                    off the stack by the operating system Block and stack methods do not limit the number or length of parameters

                    being passed

                    15
                    Exam weight Medium
                    1. Passing parameters: in registers, in a block/table in memory (address in a register), or pushed on the stack.
                    🎯 How this can come up · 1 question
                    MCQ

                    Which is NOT a way to pass parameters to a system call?

                    Slide 16: Slide 16
                    Exam weight Low
                      ★ Past exam

                      Types of System Calls

                      System Calls can be grouped into 6 categories

                      • Process control – create/terminate process, load/execute, end/abort, etc.
                      • File management- create/delete file, open/close, read/write, get/set file attributes
                      • Device management - read/write, get/set device attributes, request/release device.
                      • Information maintenance- get/set time or date, get/set file attributes, get/set process/device attributes.
                      • Protection – Control access to resources, Get and set permissions, Allow and deny user access
                      • Communications - create, delete communication connection send, receive messages if message passing model to host name or  process name From client to server   Shared-memory model create and gain access to memory regions transfer status information   attach and detach remote devices
                      17
                      Exam weight High
                      1. Types: process control, file management, device management, information maintenance, communications, protection.
                      🎯 How this can come up · 1 question
                      MCQ

                      Which system call creates a process in UNIX?

                      Slide 18: Examples of Windows and Unix System Calls
                      Exam weight Low
                        ★ Past exam
                        Slide 19: Standard C Library Example
                        Exam weight High
                        1. printf() is a C library function that eventually calls the write() system call; it is not itself a system call.
                        🎯 How this can come up · 1 question
                        True / False

                        printf() in C is a system call.

                        Operating System Structure

                        • General-purpose OS is very large program
                        • Various ways to structure ones
                          • Simple structure – MS-DOS
                          • More complex – UNIX
                          • Layered – an abstraction
                          • Microkernel – Mach
                        20
                        Exam weight Low
                          Slide 21: Linux System Structure
                          Exam weight Low
                            ★ Past exam

                            2. Layered Approach

                            • The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.

                            The system is divided into separate, smaller components that have specific and limited functionality.

                            • With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers
                            22
                            Exam weight High
                            1. Layered: layer 0 = hardware … layer N = UI; each uses only the layers below. Advantage: easy debugging and maintenance. Disadvantage: hard to define layers, overhead.
                            🎯 How this can come up · 1 question
                            Written

                            Give one advantage of the layered approach.

                            3. Microkernel System Structure

                            • Removes all nonessential components from the kernel & implementing them as system & user-level progs- smaller kernel. E.g. Mach OS
                            • Microkernel provides communication between client prog & various services that are running in user space using message passing.
                            • Benefits:
                              • extension of the OS is easier when there is less kernel to modify.
                              • easier to port the operating system to a different hardware platform because there's less kernel to reimplement.
                              • more reliable (less code is running in kernel mode).
                              • more secure (most services are running as user rather than kernel)
                            23
                            Exam weight Low
                              ★ Past exam
                              Slide 24: Microkernel System Structure
                              Exam weight High
                              1. Microkernel: move most services into user space; communicate by message passing. + easier to extend, port, more reliable and secure. − message-passing overhead.
                              🎯 How this can come up · 2 questions
                              MCQ

                              In a microkernel OS, most OS functionality runs:

                              Written

                              Give one disadvantage of the microkernel approach.

                              Slide 25: Modules
                              Exam weight Low
                              1. Loadable kernel modules: core kernel + modules loaded as needed (like layers but any module can call any other).

                              Hybrid Systems

                               Most modern operating systems actually not one pure model

                              Hybrid combines multiple approaches to address performance, security, usability

                              needs Linux and Solaris kernels in kernel address space, so monolithic, plus modular

                              for dynamic loading of functionality

                               Windows mostly monolithic, plus microkernel providing support for separate

                              subsystems that run as user-mode processes.

                              26
                              Exam weight Low
                              1. Hybrid systems mix structures: Linux/Solaris monolithic + modules; Windows mostly monolithic + microkernel parts; macOS/iOS Mach + BSD.
                              Slide 27: Operating-System Debugging
                              Exam weight Low