CS2005 Networks and Operating Systems - Operating Systems Structures and Processes

Page 1

Course Title

  • CS2005 Networks and Operating Systems

  • Authors: A. Silberschatz, P. Baer Galvin, G. Gagne

  • ©2003

Page 2

Course Overview

  • Welcome to the OS part of CS2005

  • Semester: 2

  • Week 18: Operating Systems Structures and Processes (HTTP)

  • Week 19: Threads (HTTP)

  • Week 20: Process Synchronization (Concurrency)

  • Week 21: Security (Concurrency)

  • Week 22: No Lecture (Exam Brief, TCP/UDP)

  • Week 23: Effective Learning Week

  • Weeks 24-25: No Lectures

  • Week 28: Revision Lecture (No Lectures/Labs, TCP/UDP, ICMP)

Page 3

Session Objectives

  • Describe the services an operating system provides to users, processes, and other systems.

  • Understand:

    • The meaning of a Process in an operating systems context.

    • The composition of a process and its scheduling in an operating system.

Page 4

Key Questions OS Structures

  • What are the key services of an operating system?

  • What are the main approaches to access operating system services?

  • What are system calls and system programs?

Processes

  • What is a Process?

  • How does a Process get composed?

  • What are the possible states of a Process?

  • How is a Process scheduled in an operating system?

Page 5

Variety of Operating Systems

Page 6

Multimedia Resources

Page 7

OS Structures

Page 8

Operating System Services

  • Provides an environment for program execution.

  • Offers services that differ among operating systems but have common classes.

Page 9

Key Operating System Services

  • User Interface (UI):

    • CLI (Command Line Interface), Batch Interface, GUI (Graphical User Interface).

  • Program Execution:

    • Load and run programs, normal or abnormal termination.

  • I/O Operations:

    • Indirect control of I/O devices.

  • File-system Manipulation:

    • Manage reading, writing, creating, deleting files/directories, and manage permissions.

Page 10

More Operating System Services

  • Communications:

    • Information exchange between processes, possibly on different systems.

  • Implementations: shared memory, message passing.

  • Error Detection:

    • Continuous monitoring for hardware and software errors; may lead to system halting or process termination.

Page 11

Additional OS Services

  • Resource Allocation:

    • Manage resource allocation among multiple users/jobs.

  • Accounting:

    • Track resource usage by users.

  • Protection and Security:

    • Control access to information and ensure system security from unauthorized access.

Page 12

User Interface: Command Interpreter

  • CLI allows direct command entry, sometimes implemented in the kernel or via higher-level system programs.

  • Fetches and executes commands, often with batch processing.

  • Examples: Windows cmd.exe, Unix/Linux shells (Bourne shell, C shell, BASH).

Page 13

User Interface: Batch Files

Page 14

User Interface: Graphical User Interface (GUI)

  • User-friendly interface utilizing desktop metaphors; often includes mouse and keyboard interaction.

  • Examples: Microsoft Windows GUI; Apple Mac OS GUI with UNIX kernel; Unix/Linux with optional GUI.

Page 15

Program Execution and System Calls

  • Systems must load and run programs, managing the execution process.

  • Typically use high-level languages to access OS services via APIs.

Page 16

System Calls in Detail

  • Each system call associated with a number; the interface invokes it via a kernel call and returns results.

  • Programmer follows the API without needing to know implementation details.

Page 17

System Call Execution Process

  • Flow: User application -> System call interface -> Kernel Mode implementation.

Page 18

Example: Standard C Library

  • Simple program example using standard library for output.

Page 19

System Calls: Windows and Unix Examples

  • Process Control: CreateProcess() (Windows) vs. fork() (Unix).

  • File Management: CreateFile() vs open().

  • Device Manipulation: SetConsoleMode() vs ioctl().

Page 20

Types of System Calls

  • Process control: create, terminate, load, execute processes.

  • File management: create, delete, open, close files.

  • Device management: request/release devices, I/O operations.

  • Information maintenance: get/set system data.

  • Communications: create/delete connections, send/receive messages.

Page 21

System Programs

  • Known as system utilities, providing a programming environment.

  • Can act as user interfaces to system calls or more complex services like device drivers.

Page 22

Categories of System Programs

  • File management: create, delete, or manipulate files.

  • Status information: retrieve system stats like memory or disk space.

  • File modification: text editing and transformations.

  • Programming-language support: compilers, assemblers, debuggers.

  • Program loading/execution: loaders, linkers, debuggers.

  • Communications: mechanism for virtual connections and information exchange.

Page 23

Process Management Overview

  • A process is an executing program needing resources like CPU time and memory.

  • Acts as the unit of work within systems comprising both user and OS processes.

Page 24

Understanding Processes

  • A process is created, scheduled, and maintained with various resource allocations.

  • OS roles: creation, deletion, scheduling, synchronization, communication, and deadlock handling.

Page 25

Viewing Currently Running Processes

  • Windows: use cmd (tasklist) or task manager.

  • Unix-like OS: use terminal (ps) or activity monitor.

Page 26

Process Concept

  • Definition: A process is a job, task, or user program in execution.

  • Transitions from executable program to process upon loading.

Page 27

Composition of a Process

  • Text: Program code, current activity, program counter value, CPU registers.

  • Stack: Temporary data (function parameters, return addresses).

  • Data: Global variables.

  • Heap: Dynamically allocated memory during runtime.

Page 28

Process State Changes

  • States: New, running, waiting, ready, terminated.

  • Only one process can be running; many can be ready or waiting.

Page 29

Process Control Block (PCB)

  • Represents a process in the OS containing various vital information (state, program counter, CPU registers, etc.).

Page 30

PCB Updates

  • PCBs are updated whenever a process changes state.

Page 31

CPU Process Switching Example

  • Shows process state changes when a process stops running.

Page 32

Process Scheduling

  • The scheduler chooses processes for CPU execution while keeping track of queues: job queue, ready queue, device queue.

Page 33

Process Scheduler Queues

  • Detailed representation of PCB management in different queues including ready and device queues.

Page 34

Scheduler Queuing/Lifecycle Diagram

  • Diagrams showing the process life cycle transitions among states (New, Ready, Running, Waiting, Terminated).

Page 35

Example: Process "Life" Lifecycle

  • Illustrates process transitions through various states during execution.

Page 46

Types of Schedulers

  • Short-term Scheduler: Decides next executed process, invoked frequently; must be fast.

  • Long-term Scheduler: Controls process introduction into ready queue, invoked less frequently; may be slow.