WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
os_1.pdf
1. IT305 Operating Systems
Chapter 1
Introduction
by
Dr. Arati K Manjaramkar
Asst. Professor
Dept. of Information Technology
SGGSIE&T
2. Contents
• Architecture of OS (Ex. Monolithic, Microkernel, Layered and Exokernel),
• Operating system objectives and functions,
• Interaction of O. S. and hardware architecture,
• Evolution of operating systems, Batch, Multiprogramming,
Multitasking, Multiuser, parallel, distributed & real –time O.S.,
• System calls, O. S. Shell, Linux Shell commands,
Shell programming.
• Examples of O. S.: Ubuntu, Linux, MS-Windows &
Mobile Phone O.S. (Android, Windows Phone, iOS and etc)
3. What is OS?
Operating System is a software, which makes a computer to
actually work.
It is the software the enables all the programs we use.
The OS organizes and controls the hardware.
OS acts as an interface between the application programs and the
machine hardware.
Examples: Windows, Linux, Unix and Mac OS, etc.,
4. What is OS?
A program that acts as an intermediary between a user
of a computer and the computer hardware
Operating system goals:
Execute user programs and make solving user problems
easier
Make the computer system convenient to use
Use the computer hardware in an efficient manner
5. What OS does?
An operating system performs basic tasks such as,
• Controlling and allocating memory,
• Prioritizing system requests,
• Controlling input and output devices,
• Facilitating networking and
• Managing file systems.
6. Structure of Operating System:
Application Programs
System Programs
Software (Operating System)
HARDWARE
(Contd…)
7. Structure of Operating System (Contd…):
The structure of OS consists of 4 layers:
1. Hardware
Hardware consists of CPU, Main memory, I/O Devices,
etc,
2. Software (Operating System)
Software includes process management routines, memory
management routines, I/O control routines, file
management routines.
(Contd…)
8. Structure of Operating System (Contd…):
3. System programs
This layer consists of compilers, Assemblers, linker etc.
4. Application programs
This is dependent on users need. Ex. Railway reservation
system, Bank database management etc.,
10. What Operating Systems Do
• Depends on the point of view
• Users want convenience, ease of use and good performance
• Don’t care about resource utilization
• But shared computer such as mainframe or minicomputer
must keep all users happy
• Users of dedicate systems such as workstations have
dedicated resources but frequently use shared resources from
servers
• Handheld computers are resource poor, optimized for
usability and battery life
• Some computers have little or no user interface, such as
embedded computers in devices and automobiles
11. Operating System Definition
• OS is a resource allocator
• Manages all resources
• Decides between conflicting requests for efficient and
fair resource use
• OS is a control program
• Controls execution of programs to prevent errors and
improper use of the computer
12. Evolution of OS:
The evolution of operating systems went through seven major
phases.
Six of them significantly changed the ways in which users
accessed computers through the open shop, batch processing,
multiprogramming, timesharing, personal computing, and
distributed systems.
In the seventh phase the foundations of concurrent programming
were developed and demonstrated in model operating systems.
(Contd…)
13. Evolution of OS (contd..):
Major Phases Technical
Innovations
Operating
Systems
Open Shop The idea of OS IBM 701 open shop (1954)
Batch Processing Tape batching,
First-in, first-out scheduling.
BKS system (1961)
Multi-
programming
Processor multiplexing,
Indivisible operations,
Demand paging, Input/output
spooling, Priority scheduling,
Remote job entry
Atlas supervisor (1961),
Exec II system (1966)
(Contd…)
14. Evolution of OS (contd..):
Timesharing Simultaneous user
interaction,
On-line file systems
Multics file system (1965),
Unix (1974)
Concurrent
Programming
Hierarchical systems,
Extensible kernels,
Parallel programming
concepts, Secure parallel
languages
RC 4000 system (1969),
13 Venus system (1972),
14 Boss 2 system (1975).
Personal Computing Graphic user interfaces OS 6 (1972)
Pilot system (1980)
Distributed Systems Remote servers WFS file server (1979)
Unix United RPC
(1982)
24 Amoeba system
(1990)
15. Batch Processing:
• In Batch processing same type of jobs batch (BATCH- a set of
jobs with similar needs) together and execute at a time.
• The OS was simple, its major task was to transfer control
from one job to the next.
• The job was submitted to the computer operator in form of
punch cards. At some later time the output appeared.
• The OS was always resident in memory. (Ref. Fig. next
slide)
• Common Input devices were card readers and tape drives.
16. Batch Processing (Contd…):
Common output devices were line printers, tape drives, and card
punches.
Users did not interact directly with the computer systems, but he
prepared a job (comprising of the program, the data, & some
control information).
OS
User
program
area
17. Multiprogramming:
• Multiprogramming is a technique to execute
number of programs simultaneously by a
single processor.
• In Multiprogramming, number of processes
reside in main memory at a time.
• The OS picks and begins to executes one of
the jobs in the main memory.
• If any I/O wait happened in a process, then
CPU switches from that job to another job.
• Hence CPU in not idle at any time.
18. Multiprogramming (Contd…):
OS
Job 1
Job 2
Job 3
Job 4
Job 5
• Figure dipicts the layout of
multiprogramming system.
• The main memory consists of 5
jobs at a time, the CPU executes
one by one.
Advantages:
•Efficient memory utilization
•Throughput increases
•CPU is never idle, so
performance increases.
19. Time Sharing Systems:
Time sharing, or multitasking, is a logical extension of
multiprogramming.
Multiple jobs are executed by switching the CPU between them.
In this, the CPU time is shared by different processes, so it is called as
“Time sharing Systems”.
Time slice is defined by the OS, for sharing CPU time between processes.
Examples: Multics, Unix, etc.,
20. Multiprocessing OS
Multiprocessing is the ability of an operating system to
execute more than one process simultaneously on a
multi processor machine. In this, a computer uses more
than one CPU at a time.
21. Operating Systems functions:
The main functions of operating systems are:
1. Program creation
2. Program execution
3. Input/Output operations
4. Error detection
5. Resource allocation
6. Accounting
7. protection
22. Types of OS:
Operating System can also be classified as,-
Single User Systems
Multi User Systems
23. Single User Systems:
• Provides a platform for only one user at a time.
• They are popularly associated with Desk Top
operating system which run on standalone systems
where no user accounts are required.
• Example: DOS
24. Multi-User Systems:
• Provides regulated access for a number of users by
maintaining a database of known users.
• Refers to computer systems that support two or more
simultaneous users.
• Another term for multi-user is time sharing.
• Ex: All mainframes and are multi-user systems.
• Example: Unix
25. OS Architecture
• Designs that have been tried in practice
– Monolithic systems
– Layered systems
– Virtual machines
– Client/server a.k.a. Microkernels
• Many of the concepts governing these
architectures apply to software architectures in
general
26. Monolithic Systems
• A.k.a., “The Big Mess” or spaghetti code
• Prominent in the early days
• The structure consists of no-structure
• The system is a collection of procedures
• Each procedure can call any other procedure
• No information hiding (as opposed to
modules, packages, classes)
27. Monolithic Systems (cont.’d.)
A little structure, imposed by exposing a set of system calls to the
outside
Supporting these system calls through utility procedures
(check data passed to system call, move data around …)
…
1. a main procedure requesting the services
2. a set of service procedures that carry out system calls
3. a set of utility procedures supporting the system calls
system calls
…
service procedures
utility procedures
}basic
structure
(e.g. fetching
data from user
space)
28. Pros & Cons
• Tightly integrated code in one address space
• Unreliable, as a bug anywhere in the kernel can bring down the
whole system
• Tight integration has high potential for efficient use of resources
and for efficient code
• Early designs lacked potential for extension
• Modern designs can load executable modules dynamically (i.e.,
extensible)
– E.g., Linux, FreeBSD, Solaris
29. Layered Systems
• Generalization of previous scheme
• Organization into a hierarchy of layers
• Layer n+1 uses services (exclusively) supported by
layer n
• Easier to extend and evolve
• A call may have to propagate through lots of layers
– At occasions (optimization) layer n+1 may also access layers n-k
directly
• Upcall, layer n-k calls into layer n has also been
proposed (e.g., in the context of thread scheduling)
30.
31. Microkernel System Structure
• Moves as much as possible from the kernel into “user”
space
• Communication takes place between user modules
using message passing
• Benefits:
- easier to extend a microkernel
- easier to port the operating system to new
architectures
- more reliable (less code is running in kernel mode)
- more secure (a server crashing in userspace)
• Not clear what should go into the microkernel
• Mach, QNX, NT, L4
33. Monolithic vs. Microkernel
• Mon. tend to be easier to design, therefore faster
development cycle and more potential for growth
(see Linux)
• Mon. tend to be more efficient due to use of shared
kernel memory (instead of IPC)
– However, very efficient micro kernels have been
designed in research and laboratory settings
• Micro. tend to be used for embedded systems (e.g.,
robotic, medical etc.)
• In Micro. Many OS components reside in their own,
private protected address space (not possibly in
Mon. designs)
34. Others
• Hybrid kernels (a.k.a. modified microkernel)
– Add more code to the kernel for efficiency
• Windows 2000, Windows XP
– Based on message passing
– Based on minimalist concept
– Not based on loading modules
35. Exokernel
• Traditionally
– Kernel hides hardware from application
– Based on conceptual model (files systems, virtual
address space, schedulers, sockets)
• Generally, this eases application development
• Sometimes problematic (e.g., security / privacy of
stored data upon deletion)
– Security-oriented application requires file system to
delete data
– Reliability-oriented application requires file system to
keep data for failure recovery purposes
36. • Kernel allocates physical resources to
application
• Application decides what to do with the
resources
– Application can link to a libOS to emulate a
conventional OS
– Application uses resources as it wishes
• Exokernel could emulate several OSes, one
for each application it runs
Exokernel cont’d.
37. Exokernel Summary
• Provide as few abstractions as possible
• Kernel is relatively small
– Allocates, protects, and multiplexes resources
• Low-level hardware access enables to build
custom abstractions on per application basis
– Performance reasons
• Does not force the layering of abstractions
38. Virtual Machines
• A virtual machine takes the layered approach to
its logical conclusion.
• Hardware is simulated in software; all
resources are virtualized; individual OS run on
virtualized resources
• A virtual machine provides an interface
identical to the underlying bare hardware
• The operating system creates the illusion of
multiple processes, each executing on its own
processor with its own (virtual) memory
39. Virtual Machines (Cont.)
• The resources of the physical computer are
shared to create the virtual machines.
– CPU scheduling can create the appearance
that users have their own processor.
– Spooling and a file system can provide virtual
disks, virtual memory and virtual printers.
– A normal user time-sharing terminal serves as
the virtual machine operator’s console
40. • VM model provides complete protection
• At the cost of not enabling any direct resource
sharing
• A virtual-machine system is a perfect vehicle for
operating-systems research and development.
– System development is done on the virtual machine,
instead of on a physical machine and so does not
disrupt normal system operation.
• The virtual machine concept is difficult to implement
due to the effort required to provide an exact duplicate
to the underlying machine.
Pros/Cons of Virtual Machines
41. • A shell is a program that sits between you and the raw
UNIX operating system.
There are four shells that are commonly supported by
UNIX vendors:
the Bourne shell(sh), the Korn shell(ksh), the C shell(csh)
and Bourne Again Shell (bash).
Bash (Bourne Again Shell) is compatible with Bourne
shell and borrows best features from the other shells.
Bash is becoming the most popular shell - it is the
default shell in Linux.
Unix Shells
42. We will introduce the following utilities and commands:
• Utilities
chsh kill ps
echo nohup sleep
• Shell Commands
echo kill umask
eval login wait
exec shift exit tee
Unix Shells
43. 43
SHELL INTRODUCTION
A shell is a program that is an interface between a user and
the raw operating system.
It makes basic facilities such as multitasking and piping easy
to use, and it adds useful file-specific features such as wildcards
and I/O redirection.
There are four common shells in use:
· the Bourne shell
· the Korn shell
· the C shell
· the Bash shell (Bourne Again Shell)
44. SHELL FUNCTIONALITY
- This chapter describes the common core of functionality that
all four shells provide.
Here is a diagram that illustrates the relationship among the
four shells:
Common
core
Common
core
Bourne shell
Korn shell
C shell
Bourne Again Shell
45. SHELL FUNCTIONALITY
- A hierarchy diagram is a useful way to illustrate the features
shared by the four shells
Shell functions
Built-in Scripts Variables Redirection Wildcards Pipes Sequence Subshells Background Command
Commands Processing subsitution
Local Environment Conditional Unconditional
46. SELECTING A SHELL
When you are provided with a UNIX account,
the system administrator chooses a shell for you.
To find out which shell was chosen for you, look at your prompt.
If you have a $ prompt, you’re probably in a Bash, Bourne or a
Korn shell.
If you have a % prompt, you’re probably in a C shell.
47. Utility : chsh
- chsh allows you to change your default login shell.
It prompts you for the full pathname of the new shell,
which is then used as your shell for subsequent logins.
- In order to use chsh, you must know the full pathnames of
the three shells. Here they are:
Shell Full pathname
Bourne /bin/sh
Bash /bin/bash
Korn /bin/ksh
C /bin/csh
48. SELECTING A SHELL
In the following example, we change the default login shell from
a Bourne shell to a Bash shell:
$ chsh ---> change the login shell from sh to bash.
Changing login shell for glass
Old shell : /bin/sh ---> pathname of old shell is displayed.
New shell: /bin/bash ---> enter full pathname of new shell.
$ ^D ---> terminate login shell.
login : glass ---> log back in again.
password : ---> secret.
$ _ ---> this time we are in a bash shell.
49. SELECTING A SHELL
Another way to find out the full pathname of your login shell is
to type the following:
$ echo $SHELL ---> display the name of current login shell.
/bin/bash ---> full pathname of the Korn shell.
$ -
- This example illustrated the echo shell command and a shell
variable called SHELL.
50. SHELL OPERATIONS
When a shell is invoked, either automatically during a login or
manually from a keyboard or script, it follows a preset sequence:
1. It reads a special startup file, typically located in the user’s
home directory, that contains some initialization information.
Each shell’s startup sequence is different,
so we’ll leave the specific details for later.
2. It displays a prompt and waits for a user command.
3. If the user enters a Control-D character on a line of its own,
this command is interpreted by the shell as meaning “end of
input”, and it causes the shell to terminate;
otherwise, the shell executes the user’s command and
returns to step 2.
51. SHELL OPERATIONS
Commands range from simple utility invocations like:
$ ls
to complex-looking pipeline sequences like:
$ ps -ef | sort | ul -tdumb | lp
- a command with a backslash() character, and the shell will
allow you to continue the command on the next line:
$ echo this is a very long shell command and needs to
be extended with the line-continuation character. Note
that a single command may be extended for several lines.
$ _
52. EXECUTABLE FILES VERSUS BUILT-IN COMMANDS
Most UNIX commands invoke utility programs that are stored
in the directory hierarchy.
Utilities are stored in files that have execute permission.
For example, when you type
$ ls
the shell locates the executable program called “ls”, which is
typically found in the “/bin” directory, and executes it.
53. Displaying Information : echo
The built-in echo command displays its arguments to standard
output and works like this:
Shell Command: echo {arg}*
echo is a built-in shell command that displays all of its
arguments to standard output.
By default, it appends a new line to the output.
54. Changing Directories : cd
The built-in cd command changes the current working directory
of the shell to a new location.
METACHARACTERS
Some characters are processed specially by a shell and
are known as metacharacters.
All four shells share a core set of common metacharacters,
whose meanings are as follow:
55. METACHARACTERS
Symbol Meaning
> Output redirection; writes standard output to a file.
>> Output redirection; appends standard output to a file.
< Input redirection; reads standard input from a file.
* File-substitution wildcard;
matches zero or more characters.
? File-substitution wildcard;
matches any single character.
[…] File-substitution wildcard;
matches any character between the brackets.
56. Symbol Meaning
`command` Command substitution; replaced by the output from
command.
| Pipe symbol; sends the output of one process to the
input of another.
; Used to sequence commands.
|| Conditional execution;
executes a command if the previous one fails.
&& Conditional execution;
executes a command if the previous one succeeds.
(…) Groups commands.
& Runs a command in the background.
# All characters that follow up to a new line are ignored
by the shell and program(i.e., used for a comment)
$ Expands the value of a variable.
Prevents special interpretation of the next character.
<<tok Input redirection; reads standard input from script up to tok.