Operating Systems Structures
Operating Systems Structures
and Structure
Dr. M. Brindha
Associate Professor
Department of CSE
NIT, Trichy-15
Operating System Services-User
• Operating systems provide an environment for
execution of programs and services to programs and
users
• One set of operating-system services provides
functions that are helpful to the user:
• User interface - Almost all operating systems have a user
interface (UI).
• Varies between Command-Line (CLI), Graphics User Interface
(GUI), touch-screen, Batch
• Program execution - The system must be able to load a
program into memory and to run that program, end
execution, either normally or abnormally (indicating error)
• I/O operations - A running program may require I/O, which
may involve a file or an I/O device
• File-system manipulation - The file system is of particular
interest. Programs need to read and write files and
directories, create and delete them, search them, list file
Information, permission management.
Operating System Services-User (Cont.)
• One set of operating-system services provides
functions that are helpful to the user (Cont.):
• C o m m u n i c a t i o n s – P r o c e s s e s m a y e xc h a n g e
information, on the same computer or between
computers over a network
• Communications may be via shared memory or through
message passing (packets moved by the OS)
• Error detection – OS needs to be constantly aware of
possible errors
• May occur in the CPU and memory hardware, in I/O devices,
in user program
• For each type of error, OS should take the appropriate action
to ensure correct and consistent computing
• Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system
Operating System Services-System (Cont.)
• Another set of OS functions exists for ensuring the
efficient operation of the system itself via resource
sharing
• Resource allocation - When multiple users or multiple jobs
running concurrently, resources must be allocated to each of
them
• Many types of resources - CPU cycles, main memory, file storage,
I/O devices.
• Logging - To keep track of which users use how much and
what kinds of computer resources
• Protection and security - The owners of information stored
in a multiuser or networked computer system may want to
control use of that information, concurrent processes should
not interfere with each other
• Protection involves ensuring that all access to system resources is
controlled
• S e c u r i t y o f t h e sy s t e m f ro m o u t s i d e r s r e q u i r e s u s e r
authentication, extends to defending external I/O devices from
invalid access attempts
A View of Operating System Services
Command Line interpreter
• CLI allows direct command entry
• Sometimes implemented in kernel, sometimes by
systems program
• Sometimes multiple flavors implemented – shells
• Primarily fetches a command from user and
executes it
• Sometimes commands built-in, sometimes just
names of programs
Bourne Shell Command Interpreter
User Operating System Interface - GUI
Device Drivers
11
Operating System Structure
• General-purpose OS is very large program
• Various ways to structure ones
• Simple structure – MS-DOS
• More complex – UNIX
• Layered – an abstraction
• Microkernel – Mach
OS Structure : Monolithic Structure
User Space Processes
System Call Interface
Memory CPU File System
Kernel space
13
Monolithic Structure – Original UNIX
• UNIX – limited by hardware functionality, the
original UNIX operating system had limited
structuring.
• The UNIX OS consists of two separable parts
• Systems programs
• The kernel
• Consists of everything below the system-call interface and
above the physical hardware
• P ro v i d e s t h e f i l e syste m , C P U s c h e d u l i n g , m e m o r y
management, and other operating-system functions; a large
number of functions for one level
Monolithic Structure – Original UNIX
• Monolithic kernel is a single large process running
entirely in a single address space.
• It is a single static binary file.
• All kernel services exist and execute in the kernel
address space.
• The kernel can invoke functions directly.
• Examples of monolithic kernel based OSs:
Traditional Unix, Linux.
Traditional UNIX System Structure
Beyond simple but not fully layered
Linux System Structure
Monolithic plus modular design
Layered Approach
• The operating system is
divided into a number of
layers (levels), each built
on top of lower layers.
The bottom layer (layer
0), is the hardware; the
highest (layer N) is the
user interface.
• With modularity, layers
are selected such that
each uses functions
(operations) and
services of only lower-
level layers
OS Structure : Microkernel
• Highly modular.
User Space Processes
– Every component has its own
space.
– Interactions between
Management
Process
Drivers
Server
Microkernel
(interprocess communication, communication and scheduling
scheduling)
– Everything else in user space.
– Ideally kernel is so small that it
Eg. QNX and L4 fits the first level cache
19
Microkernels
• Moves as much from the kernel into user space
• Mach is an example of microkernel
• Mac OS X kernel (Darwin) partly based on Mach
• Communication takes plac e 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
• Detriments:
• Performance overhead of user space to kernel space
communication
Microkernels
• In microkernels, the kernel is broken down into
separate processes, known as servers.
• Some of the servers run in kernel space and some
run in user-space.
• All servers are kept separate and run in different
address spaces.
• Servers invoke "services" from each other by
sending messages via IPC (Interprocess
Communication).
• This separation has the advantage that if one
server fails, other servers can still work efficiently.
• Examples of microkernel based OSs: Mac OS X and
Windows NT.
Microkernel System Structure
Monolithic vs Microkernels
Monolithic Microkernel
23
Modules
• Many modern operating systems implement
loadable kernel modules (LKMs)
• 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 flexible
•Modules are similar to layers each subsystem has clearly defined
tasks and interfaces,
•any module is free to contact any other module without going through
multiple intermediary layers.
•The kernel is relatively small in this architecture, similar to
microkernels, but the kernel does not have to implement message
passing since modules are free to contact each other directly.
Modules
• In modern-day approach to monolithic architecture,
the kernel consists of different modules which can be
dynamically loaded and unloaded.
• This modular approach allows easy extension of OS's
capabilities.
• With this approach, maintainability of the kernel also
has become easy as only the concerned module
needs to be loaded and unloaded every time there is
a change or bug fix.
• Also, because of this dynamic loading and unloading
of the modules, stripping down the kernel for smaller
platforms (like embedded devices, etc.) became easy
too.
• UNIX-Modular Monolithic Structure
Hybrid Systems
• Most modern operating systems are 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
functionality
• Windows mostly monolithic, plus microkernel for
different subsystem personalities (called kernel
extensions)
Virtual Machines
Hardware Hardware
No virtual Machines With virtual Machines
29
Example: Arduino
• Single-tasking
• No operating system
• Programs (sketch)
loaded via USB into
flash memory
• Single memory space
• Boot loader loads
program
• Program exit -> shell
reloaded At system startup running a program
Example: FreeBSD
• Unix variant
• Multitasking
• User login -> invoke user’s choice
of shell
• Shell executes fork() system call to
create process
• Executes exec() to load program into
process
• Shell waits for process to terminate
or continues with user commands
• Process exits with:
• code = 0 – no error
• code > 0 – error code
Thank You!!!