Docsity

OS Structures & Services: Comm, Sys Calls, UIs & VMs, Slides of Computer Science

Partial preview of the text

Download OS Structures & Services: Comm, Sys Calls, UIs & VMs and more Slides Computer Science in PDF only on Docsity!

1

Operating System Structures

Chapter 2

2

Operating System Services

  • User interface - Almost all operating systems have a user interface (UI)
    • Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch
  • Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)
  • I/O operations - A running program may require I/O, which may involve a file or an I/O device.
  • File-system manipulation - The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.
  • Communications – Processes may exchange information, on the same computer or between computers over a network - Communications may be via shared memory or through message passing (packets moved by the OS)

4

User Operating System Interface - CLI

CLI allows direct command entry

  • Sometimes implemented in kernel, sometimes by

systems program

  • Sometimes multiple flavors implemented – 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
  • Example: Unix shell programming

5

MS-DOS execution

(a) At system startup (b) running a program

7

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
  • Many systems now include both CLI and GUI interfaces
    • Microsoft Windows is GUI with CLI “command” shell
    • Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available
    • Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)

8

System Calls

  • Programming interface to the services provided by the OS
  • 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)
  • Why use APIs rather than system calls?

(Note that the system-call names used throughout this text are generic)

11

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 need 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

Standard C Library Example

  • C program invoking printf() library call, which

calls write() system call

15

Parameter Passing via Table

16

Types of System Calls

• Process control

• File management

• Device management

• Information maintenance

• Communications

18

Operating System Design and

Implementation

  • Design and Implementation of OS not “solvable”, but
some approaches have proven successful
  • Internal structure of different Operating Systems can
vary widely
  • Start by defining goals and specifications
  • Affected by choice of hardware, type of system
  • User goals and System goals
    • User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast
    • System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient

19

Operating System Design and

Implementation (Cont.)

  • 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

21

UNIX: Also “Simple” Structure

• UNIX – limited by hardware functionality

• Original UNIX operating system consists of two

separable parts:

  • Systems programs
  • The kernel
    • Consists of everything below the system-call interface and above the physical hardware
    • Provides the file system, CPU scheduling, memory management, and other operating-system functions;
    • Many interacting functions for one level

22

UNIX System Structure

User Mode

Kernel Mode

Hardware

Applications

Standard Libs