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

OS - Lecture # 05 - Operating System Structure

operating system structure

Uploaded by

ahmedsoban648
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

OS - Lecture # 05 - Operating System Structure

operating system structure

Uploaded by

ahmedsoban648
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

‫ﷲ �اﻟﺮ ٰﲪ ِﻦ �اﻟﺮﺣﲓِ‬

‫�ِﺴ ِﻢ ِ‬
‫ۑ‬ ‫‪۷‬‬ ‫‪٥‬‬ ‫‪۶‬‬ ‫‪۹ ٥‬‬ ‫‪۷‬‬
‫‪ἐ‬‬ ‫‪۸‬‬ ‫ہ‬ ‫‪٦‬‬ ‫‪٦‬‬ ‫ﯧ‬
‫‪٦‬‬ ‫╖‬
‫ڮ ‪ּĭ‬ڹڮ┤ּ ﮩڵּ �ڶ┼≡ּ ڶּﮥ ڵ‪ṟ˨ּδ‬ڶڹڮ┬ּ‪Ṏ‬ڮ>ڹڰּ↑ ﮘּ┼‪˃δ‬ﯖּ �ڵ ·‬ ‫▲‬ ‫‪ʳ‬‬ ‫╕‬
‫‪Ḋ‬‬
‫ڴּڼ‪Ѳ‬ڮ ڴּ ‪ɢ‬ڵּڹ‪٪‬‬‫‪ʬδ‬‬

‫‪1‬‬
Operating System Structure

Lecture # 05
By: Muhammad Ehsan
Lecturer
Department of Computer Science

2
Operating System Structure

3
Lecture Outline

 User and Operating-System Interface


 System Calls
 Types of System Calls
 System Programs

4
User and Operating-System
Interface

5
Command-line interface

CLI or command interpreter allows direct command entry


Sometimes implemented in kernel, sometimes by systems program
Sometimes multiple flavors implemented – shells
o For example, on UNIX and Linux systems, a user may choose
among several different shells, including the Bourne shell, C shell,
Bourne-Again shell, Korn shell, and others
Primarily fetches a command from user and executes it
Sometimes commands built-in, sometimes just names of programs
6
Bourne Shell Command Interpreter

7
Graphical User Interfaces
 User-friendly desktop metaphor interface
o Usually mouse, keyboard, and monitor
o Icons represent files, programs, actions, etc
o Various mouse buttons over objects in the interface cause various actions
(provide information, options, execute function, open directory (known as a
folder)
 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
8
 Unix and Linux have CLI with optional GUI interfaces (CDE, KDE, GNOME)
Touchscreen Interfaces

 Touchscreen devices require new


interfaces
o Mouse not possible or not desired
o Actions and selection based on
gestures
o Virtual keyboard for text entry
o Voice commands.

9
The Mac OS X GUI

10
System Calls

11
System Calls

System calls provide an interface to the services made available


by an Operating System.

User mode

Kernel
Privileged mode
Mode

12
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
Programming 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)

13
Example of System Calls
Example of a System Call sequence for writing a simple program to
read data from one file and copy them to another file:

Source File Destination File


Acquire Input Filename
Write prompt to screen
Accept Input

Acquire Output Filename

Write prompt to screen


Accept Input 14
Example of System Calls
Source File Acquire Input Filename
Destination File
Write prompt to screen
Accept Input
Acquire output Filename
Write prompt to screen
Accept Input

Open Input File


If File doesn't exist, ABORT
Create Output File
If File exists, ABORT
Loop Read from Input File
Until Read fail Write to Output File
15
Close Output File
Example of System Calls
Acquire Input Filename
Source File Destination File
Write prompt to screen
Accept Input
Acquire output Filename
Write prompt to screen
Accept Input
Open Input File
If File doesn't exist, ABORT
Loop Create Output File
Until Read fail
If File exists, ABORT
Read from Input File
Write to Output File
Close Output File

Write completion message to screen


16
Terminate normally
Example of Standard API

17
System Call Implementation

 Typically, a number associated with each system call


o System-call interface maintains a table indexed according to these
numbers
 The system call interface invokes the 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
o Just needs to obey API and understand what OS will do as a result call
o 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) 18
API – System Call – OS Relationship

19
Types of System Calls

20
Types of System Calls

System calls can be grouped roughly into five major categories:


1. Process Control
2. File Manipulation
3. Device management
4. Information Maintenance
5. Communications

21
Types of System Calls

Process control
create process, terminate process
end, abort
load, execute
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory

22
Types of System Calls

File management
create file, delete file
open, close file
read, write, reposition
get and set file attributes

23
Types of System Calls

Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
Information maintenance
get time or date, set time or date
get system data, set system data
get and set process, file, or device attributes
24
Types of System Calls

Communications
create, delete communication connection
send, receive messages if message passing model to host name or
process name
o From client to server
Shared-memory model create and gain access to memory regions
transfer status information
attach and detach remote devices

25
Types of System Calls

Protection
Control access to resources
Get and set permissions
Allow and deny user access

26
Examples of Windows and Unix System Calls

27
Standard C Library Example

C program invoking printf() library call, which calls write() system


call

28
System Programs

29
System Programs
 An important aspect of a modern system is the collection of system
programs.

-----Application Program-----
System program

Resources like CPU,


Memory, I/O devices 30
System Programs
 System programs provide a convenient environment for program
development and execution. They can be divided into:
o File manipulation
o Status information sometimes stored in a File modification
o Programming language support
o Program loading and execution
o Communications
o Background services
o Application programs

31
System Programs
 Most users’ view of the operation system is defined by system programs,
not the actual system calls
 Provide a convenient environment for program development and
execution
 Some of them are simply user interfaces to system calls; others are
considerably more complex

32
System Programs
 File management:
 Create, delete, copy, rename, print, dump, list, and generally manipulate files
and directories
 Status information
o Some ask the system for info - date, time, amount of available memory, disk
space, number of users
o Others provide detailed performance, logging, and debugging information
o Some systems implement a registry - used to store and retrieve
configuration information

33
System Programs
 File modification
o Text editors to create and modify files
o Special commands to search contents of files or perform
transformations of the text
 Programming-language support
o Compilers, assemblers, debuggers and interpreters sometimes
provided
• for common programming languages (such as C, C++, Java,Visual
Basic, and PERL) are often provided to the user with the operating
system.
34
System Programs
 Program loading and execution
o Once a program is assembled or compiled, it must be loaded into
memory to be executed.
o Absolute loaders, relocatable loaders, linkage editors, and overlay-
loaders, debugging systems for higher-level and machine language
 Communications
o Provide the mechanism for creating virtual connections among
processes, users, and computer systems
o Allow users to send messages to one another’s screens, browse web
pages, send electronic-mail messages, log in remotely, transfer files
35
from one machine to another
System Programs

 Background Services
o Launch at boot time
o Some for system startup, then terminate
o Some from system boot to shutdown
o Provide facilities like disk checking, process scheduling, error logging,
printing
o Run in user context not kernel context
o Known as services, subsystems

36
System Programs

In addition to systems programs, most operating systems are supplied with


programs that are useful in solving common problems or performing
common operations.
 Application programs
o Don’t pertain to system
o Run by users
o Not typically considered part of OS
o Launched by command line, mouse click, finger poke

37
JAZAK ALLAH!
Any Question?

38

You might also like