0% found this document useful (0 votes)
21 views

Week 2 - Operating System Structures

Here is a C program that simulates the creation of a process and prints the process ID: #include <stdio.h> #include <unistd.h> int main() { pid_t pid; printf("Creating process...\n"); pid = fork(); if (pid < 0) { printf("Fork failed!\n"); } else if (pid == 0) { printf("I am child process with PID %d\n", getpid()); } else { printf("I am parent process with child PID %d\n", pid); } return 0; } This program uses the fork() system call to create
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Week 2 - Operating System Structures

Here is a C program that simulates the creation of a process and prints the process ID: #include <stdio.h> #include <unistd.h> int main() { pid_t pid; printf("Creating process...\n"); pid = fork(); if (pid < 0) { printf("Fork failed!\n"); } else if (pid == 0) { printf("I am child process with PID %d\n", getpid()); } else { printf("I am parent process with child PID %d\n", pid); } return 0; } This program uses the fork() system call to create
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

OPERATING

SYSTEM
STRUCTURE
S
REMINDERS

Prelim
Examination
March 23,
2023
To describe the services that the OS
provides to users, processes and
OBJECTIVES other systems

To discuss the various ways of


LEARNING

structuring an operating system.

To explain how OS are installed and


customized and how they boot.
TOPICS
• Operating System Services
• User and Operating System
Interface
• System Calls
• System Programs
• OS Design & Implementation
• OS Structure
• OS Debugging
• OS Generation
• System Boot
• Operating System Services are provided for
the programmer’s convenience, to make
programming tasks easier.

OPERATING • One set of services provides functions that


SYSTEM are helpful to the user.
SERVICES

• One set of functions exist for ensuring the


efficient operation of the system itself.
OPERATING SYSTEM SERVICES
USER AND OTHER SYSTEM PROGRAMS

GUI BATCH COMMAND LINE

USER INTERFACES

SYSTEM CALL

PROGRAM
SERVICES

I/O OPERATION FILE SYSTEM COMMUNICATION


EXECUTION
RESOURCE ERROR PROTECTION &
ACCOUNTING
ALLOCATION DETECTION SECURITY
OPERATING SYSTEM
HARDWARE
USER and
OPERATIN • Command Interpreters
G SYSTEM
INTERFAC • Graphical User Interfaces
E • Choice of Interface
• The main function of the command interpreter is
to get and execute the next user-specified
command.

COMMAND
INTERPRETE
• There are two-way to do it:
RS • The command interpreter itself contains the
code to execute the command
• The command interpreter does not
understand the command in any way and
merely uses the command to identify the file
to be loaded into memory and executed.
• Users employ a mouse-based window and
menu system characterized by a:
• Desktop
GRAPHICA
L USER
• Icons
INTERFAC • Folders
ES • Mobile Systems like smartphones and
tablets used touchscreen interfaces
instead of mouse due to impracticality.
• The choice of whether to use a command-line or GUI interface is mostly one
of personal preference
SYSTEM CALLS
SOURCE FILE DESTINATION FILE

EXAMPLE SYSTEM CALL SEQUENCE


Acquire Input File Name
Write prompt to screen
Accept Input
Acquire Output File Name
Write prompt to screen
Accept Input File
Open the Input File
If File doesn’t exist Abort
Create output File
If File exist abort
Loop
Read from input File
Write to output File
Until read Fails
Write completion message to screen
Terminate normally
• System calls provide an interface to the
services made available by an operating
system. These calls are generally available as
routines written in C and C++, although
certain low-level task may have to be written
using assembly-language instructions.
SYSTEM CALLS
• Application Programming Interface (API)
specifies a set of functions that are available
to an application programmer, including the
parameters that are passed to each function
and return values the programmers can
expect.
API-System Call-OS Relationship
USER APPLICATION

open ()

User
Mode
SYSTEM CALL INTERFACE
Kernel
Mode open()
Implementation of
open() system call
.
.
.
return
TYPES OF
SYSTEM CALLS
• Process Control
• File Manipulation
• Device Manipulation
• Information Maintenance
• Communications
• Protection
• File Management
• Status Information
• File Modification
SYSTEM
PROGRAMS
• Programming Language Support
• Program Loading and execution
• Communication
• Background Services
SANITY
BREAK
We will resume by:
10:00 am
• Design Goals
• Mechanisms and Policies
OS Design
• Implementation
• Define Goals and Specification

• User Goals and System Goals


• User goals – the operating system should
DESIGN GOALS be convenient to use, easy to learn,
reliable, safe, and fast

• System goals – the operating system


should be easy to design, implement,
and maintain, as well as flexible, reliable,
error-free, and efficient
MECHANIS • Separate Mechanisms and Policies
M and • It allows maximum flexibility if policy decisions are to be changed
later
POLICIES
• Many variations
• Early OSes in assembly language
• Then system programming languages like Algol, PL/1
• Now C, C++
• Actually usually a mix of languages
IMPLEMENTATIO • Lowest levels in assembly
N
• Main body in C
• Systems programs in C, C++, scripting languages like PERL,
Python, shell scripts
• More high-level language easier to port to other hardware
• But slower
• Emulation can allow an OS to run on non-native hardware
• Simple Structure
• Layered Approach
OS Structure
• Microkernels
• Modules
• Hybrid Systems
SIMPLE STRUCTURE
APPLICATION PROGRAM

RESIDENT SYSTEM PROGRAM

MS DOS DEVICE DRIVER

ROM BIOS DEVICE DRIVERS


LAYERED APPROACH

LAYER 3

LAYER 2

LAYER 1

LAYER 0
MICROKERNELS

USER MODE
APPLICATION
PROGRAM FILE SYSTEM DEVICE DRIVER

MESSAGES MESSAGES

KERNEL MODE
INTERPROCESS MEMORY
CPU SCHEDULING
COMMUNICATION MANAGEMENT

MICROKERNEL

HARDWARE
MODULES
Scheduling
Classes

Loadable
File Systems
System Calls

Core
Kernel
Executable Device and
Formats Bus Drivers

STREAM Miscellaneou
Modules s Modules
• Most modern operating systems are 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
HYBRID functionality

SYSTEM • Windows mostly monolithic, plus microkernel for


different subsystem personalities
• Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa
programming environment
• Below is kernel consisting of Mach microkernel and
BSD Unix parts, plus I/O kit and dynamically loadable
modules (called kernel extensions)
• Failure Analysis
OS
• Performance Tuning
DEBUGGING
• Dtrace
• Operating systems are designed to run on
any of a class of machines; the system
must be configured for each specific
computer site

OS • SYSGEN program obtains information


Generation concerning the specific configuration of
the hardware system
• Used to build system-specific compiled
kernel or system-tuned
• Can general more efficient code than
one general kernel
PROGRAM FOR SYSTEM CALLS
(fork, getpid exit)

Create Create a program that will simulate the creation of a process.

Get If the process is generated successfully, get the process id and print it

Exit Exit the program.

You might also like