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

CMP320 Operating Systems Operating System Structures: FALL 2017 Syed Abrar Ahmad

The document discusses different structures used in operating system design, including simple/monolithic structures, layered approaches, microkernels, and module-based structures. It provides examples of each type such as MS-DOS for simple structures, THE operating system for layered approaches, and Mach and Windows NT for microkernel designs. The document also briefly discusses the history of UNIX and provides an overview of basic UNIX shell commands.

Uploaded by

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

CMP320 Operating Systems Operating System Structures: FALL 2017 Syed Abrar Ahmad

The document discusses different structures used in operating system design, including simple/monolithic structures, layered approaches, microkernels, and module-based structures. It provides examples of each type such as MS-DOS for simple structures, THE operating system for layered approaches, and Mach and Windows NT for microkernel designs. The document also briefly discusses the history of UNIX and provides an overview of basic UNIX shell commands.

Uploaded by

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

CMP320

Operating Systems
Lecture 03

Operating System Structures


FALL 2017
Syed Abrar Ahmad
Note: Some slides and/or pictures are adapted from Lecture slides / Books of
• Dr Mansoor Sarwar.
• Arif Butt
• Dr Kubiatowicz.
• Dr Hank Levy.
• Dr Indranil Gupta.
• Text Book - OS Concepts by Silberschatz, Galvin, and Gagne.
• Ref Books
• Operating Systems Design and Implementation by Tanenbaum.
• Operating Systems by William Stalling.
• Operating Systems by Colin Ritchie.
Today’s Agenda

• Review of Previous Lecture

• OS Structures
– Simple Structures

– Layered Approach

– Micro kernels

– Module Based

• Basic UNIX Shell Commands


10/16/2017 CMP320 PUCIT Abrar Shah 2
OS Structures
• A system as large and complex as a modern OS
must be engineered carefully if it is to function
properly and be modified easily
• A common approach is to partition the task into
small components rather than have one monolithic
system
• Each of these modules should be a well defined
portion of the system, with carefully defined
inputs, outputs and functions

10/16/2017 CMP320 PUCIT Abrar Shah 3


Simple Structures (Monolithic)
• The monolithic systems can also be subtitled as a “Big Mess”. The
structure is that there is no structure
• The OS is written as a collection of procedures, each of which can call
any of the other ones whenever it needs to
• Each procedure in the system has a well-defined interface in terms of
parameters and results, and each one is free to call any other one, if
the later provides some useful computation that the former needs
• There is no information hiding; every procedure is visible to every
other procedure
• Even in monolithic systems, however, it is possible to have at least a
little structure. The system calls provided by the OS are requested
by putting the parameters in well-defined places, such as in registers
or on the stack, and then executing a special trap instruction known as
kernel call

10/16/2017 CMP320 PUCIT Abrar Shah 4


Simple Structures (cont…)

MS-DOS
10/16/2017 CMP320 PUCIT Abrar Shah 5
Simple Structure (cont…)
• UNIX consists of two separate parts, System Programs and the
Kernel
• Every thing below the system call interface and above the physical
h/w is the kernel. Provides the file system, CPU scheduling, memory
management, and other operating-system functions
• An enormous amount of functionality combined in one level, UNIX is
difficult to enhance as changes in one section could adversely affect
other areas

Applications
User Mode
Standard Libs

Kernel Mode

Hardware
10/16/2017 CMP320 PUCIT Abrar Shah 6
Layered Approach
• OS is broken up into a number of layers (levels)
each built on the top of other
• The Bottom layer is the hardware layer and the
topmost layer ( layer N) is the user interface
• A typical layer consists of data structures and a
set of routines to service the layer above it
• Examples:
• THE operating system by Dijkstra
• IBM’s OS/2

10/16/2017 CMP320 PUCIT Abrar Shah 7


Layered Approach

10/16/2017 CMP320 PUCIT Abrar Shah 8


Layered Approach (cont…)
Advantages
• Simplifies debugging and system verification. If an error is found
during debugging of a particular layer, the error must be in that layer,
because the layers below it are already debugged
• Abstraction. Each layer is implemented with only those operations
provided by lower level layers. A layer does not need to know how
these operations are implemented. This hides the existence of certain
data structures, operations and hard ware from higher level layers

Difficulties in designing layered approach


• Careful definition of layers, because a layer can only use the layers
below it; a functionality required by layer M must be defined in layer
M-1
• Less efficient approach; e.g. when a program executes an I/O
operation, it executes a system call that is trapped to the I/O layer,
which in turn call the memory mgmt layer, which in turn call the CPU
scheduling layer which is then passed to h/w. At each layer
parameters may be modified, data may need to be passed and so on
10/16/2017 CMP320 PUCIT Abrar Shah 9
Layered Approach (cont…)
THE (Technische Hogeschool Eindhoven, Netherlands) System (Dijkstra - 1968)
• THE system was a simple batch system for a Dutch
computer, the Electrologica X8, which had 32K of 27 bit
words
• Each layer presents an enhanced virtual machine to the
layer above. Each layer can be tested and verified
independently
Layer 5: The operator
Layer 4: User Programs
Layer 3: Input/Output management
Layer 2: Operator-process communication
Layer 1: Memory and drum management
Layer 0: Processor allocation and multiprogramming
10/16/2017 CMP320 PUCIT Abrar Shah 10
Microkernel
• In mid 1980s, researchers at Carnegie Mellon University
developed an OS called Mach that modularized the kernel
using the microkernel approach
• A microkernel provides a communication facility between
client programs and various services running in user space
• Goals
• Minimize what goes in kernel
• Organize rest of OS as user level processes
• Only few essential services / functions are assigned to the
kernel; e.g. address space checking, IPC and basic scheduling.
Other OS services (file service, memory service, terminal
service, process service) are given to servers that run in user
mode and are treated like any other application by the
microkernel
• First microkernel system was Hydra (CMU, 1970), Mach(CMU), and in
some ways NT (Microsoft), OS X (Apple) 11
10/16/2017 CMP320 PUCIT Abrar Shah
Microkernel (cont…)

Microkernel Structure

10/16/2017 CMP320 PUCIT Abrar Shah 12


Microkernel (cont…)
Win NT Client-Server Architecture
To request a service, such as reading a block of a file, a
user process / client process sends a request to a server
process, which then does the work and sends back the
answer. Kernel dose all the communication.

10/16/2017 CMP320 PUCIT Abrar Shah 13


Microkernel (cont…)
Advantages
• Easier to extend OS (New services are added to user space and
consequently do not require modification of the kernel or its
recompilation)
• Easer to port from one h/w to another
• More security and reliability (less code is running in microkernel)
• Fault Isolation. Since all the servers run as user-mode processes,
and not in kernel mode, they do not have direct access to the h/w.
As a consequence, if a bug in the File Server is triggered, the file
service may crash, but this will not usually bring the whole system
down
Disadvantages
• Performance decreases due to extensive message passing (IPC)
10/16/2017 CMP320 PUCIT Abrar Shah 14
Modules Based Structure
• Most modern operating systems implement modules:
• Uses object-oriented approach
• Each core component is separate
• Each talks to the others over known interfaces
• Each is loadable as needed within the kernel
• Overall, similar to layers but with more flexibility
• Solaris OS

10/16/2017 CMP320 PUCIT Abrar Shah 15


History of UNIX
• Ken Thompson found a PDP-7, and set
out to write a stripped down one-user
version of MULTICS. This work later
developed into the UNIX operating
system.
Ken Thompson Dennis Ritchie

• Since the source code of UNIX was widely available,


various organizations developed their own versions, which
led to chaos as far as UNIX history is concerned.
• Two major versions developed:
• System V, from AT&T
• BSD (Berkley Software Distribution from UC Berkeley)
Minor variation includes FreeBSD, OpenBSD and NetBSD.
• To make it possible to write programs that could run on
any UNIX system, IEEE developed a standard for UNIX,
called POSIX, that most versions of UNIX now support.
10/16/2017 CMP320 PUCIT Abrar Shah 16
UNIX is basically a Simple Operating System

But YOU have to be a GENIUS to understand the Simplicity

Dennis Ritchie

10/16/2017 CMP320 PUCIT Abrar Shah 17


UNIX Shell Commands
• A shell command can be internal/built-in or External
• The code to execute an internal command is part of the
shell process, e.g., cd, dot, echo, pwd.
• The code to process an external command resides in a file
in the form of a binary executable program file or a shell
script, e.g., cat, ls, mkdir, more.
• The general syntax of a shell command is
command [option(s)] [argument(s)]
• After reading the command the shell determines whether
the command is internal or external
• It processes all internal commands by using the
corresponding code segments that are within its own code
• To execute an external command, it searches the
command in the search path. Directories names stored in
the PATH variable. [echo $PATH]
10/16/2017 CMP320 PUCIT Abrar Shah 18
Important Shell Commands
Command Description
logout/exit/^D
date Prints or sets the system date and time
cal Displays the calendar for a specified month or a year
whoami, who, w, finger, users User Information look up programs
passwd Used to change the user password
echo Copies its arguments back to the terminal
man [-k] Displays online documentation
lpr Line printer prints the contents of specified files to printer
tty Display the name of terminal you are using
stty Sets or unsets selected terminal I/O options
script Used to record an interactive session
whereis Locate the binary, source and man page files for a command
uname Print system information
alias, unalias Used to create / remove alias
bc Calculator
clear Clear the terminal screen

10/16/2017 CMP320 PUCIT Abrar Shah 19


Important Shell Commands (…)
Operations Unique to Directories
Command Description
pwd Present working directory
ls [-aildpFR] List directory contents
mkdir [-pm] Creates directory(ies)
cd, cd -, cd ~, cd .., cd ../../.. Change current working directory
rmdir [-p] dirnames Remove empty directories specified in dirnames
Operations Unique to Files
Command Description
touch filename Change file time stamps if file exist otherwise create file
less/more filename Displays file contents page by page
head, tail[-f] filename Output the first/last ten lines of the file
cat[-n] filename Concatenate / displays the files in stdout
grep arif /etc/passwd Print lines matching a pattern
uniq filename Remove adjacent matching lines and send o/p to stdout
wc[-lwc] filename Prints the number of newlines, words, and bytes in file
sort filename Sort lines of text files
file filename Display the type of file

10/16/2017 CMP320 PUCIT Abrar Shah 20


Important Shell Commands (…)
Operations Common to Both Files and Directories

Command Description
cp [-frip] srcdirs/files destdir/files Copies files and directories
mv [-fri] srcdirs/files destdir/files Move /Cut files and directories
rm [-fri] dirs/files Delete files and directories
find /etc/ -name passwd Search for file in a directory hierarchy
tar cvf archname.tar dirs/files Archive dirs/files in the current working directory
tar tvf arcname.tar View archived files/dirs in archname.tar
tar xvf archname.tar Extract archived files/dirs in the current working directory

10/16/2017 CMP320 PUCIT Abrar Shah 21


Important Shell Commands (…)
Command Description
write username [terminal] Write on the terminal screen or console window of the user
talk username [terminal] with log-in name username
mesg y/n Enables or disables requests from other users for talk
useradd, userdel username Adds/deletes user from a system
gzip, gunzip Gzip replaces the file with filename.gz
hostname Displays the host name
telinit Used to change the run level
env Displays the environment variables
Output absolute pathnames for the files containing binaries,
whereis file-list
source codes, and manual pages for the commands in file-list
Cut out specified fields of a table in a file and display on
cut[-f1,3,4] /etc/passwd
stdout
paste std_addr std_result Horizontally concatenate files in file-list
crypt key <origfile> Used for encryption, key is the password to be used to
encryptedfile perform encryption
Used for decryption, key should be same used for
crypt key <encryptedfile> origfile
encryption

10/16/2017 CMP320 PUCIT Abrar Shah 22


UNIX Manuals
• Don’t expect to remember everything… I don’t!
• Unix manual has 8 sections
• 1 – Shell commands; e.g., mv, ls, cat, …
• 2 – System calls; e.g., read(), write(), open(), …
• 3 – Library calls; e.g., printf(), scanf(), …
• 4 – Device & NW specific information
• 5 – File Formats; e.g., /etc/passwd, /etc/shadow,
• 6 – Games & demos; e.g., fortune, worms, …
• 7 – Miscellaneous; e.g., ascii character map, …
• 8 – Admin functions; e.g., fsck, network daemons
10/16/2017 CMP320 PUCIT Abrar Shah 23
UNIX Manuals
Every Unix manual page has seven general parts:
• Name
• Synopsis
• Description
• List of files
• Related Information
• Errors
• Warnings
• Known Bugs

10/16/2017 CMP320 PUCIT Abrar Shah 24


UNIX Editors

There are various editors available in UNIX.


• vi/ vim
• emacs
• pico
• gedit

10/16/2017 CMP320 PUCIT Abrar Shah 25


SUMMARY

10/16/2017 CMP320 PUCIT Abrar Shah 26


We’re done for now, but
Todo’s for you after this
lecture…
• Go through the slides and Book Sections: 2.7, 2.8
• Install vmware and then RHEL on your personal machine
• Log in and run basic shell commands. You must execute
all commands from the UNIX tutorial available at dbsrv
• Use UNIX’s vim editor and write ten draw backs of this
course (not of instructor); one draw back per line. Save the
file with the name drawbacks.txt

If you have problems (in finding drawbacks) visit me in counseling hours. . . .

10/16/2017 CMP320 PUCIT Abrar Shah 27

You might also like