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

Lecture 3

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

Lecture 3

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

CSE 2024

Operating System
Lecture 3
Introduction to System Programing
Saurabh Mishra, PhD
Assistant Professor
Dept of CSE
Content
• System Programming
• OS Design and Implementation
• OS Structure
• OS Generation
• OS Boot
Why Applications Are Operating-System
Specific??
• Clearly, if we want to run a program on a computer, we have to
write the instructions in the machine language understood by the
computer.
• Also, programs need to make system calls, and different operating
systems have different APIs and/or different sets of system calls.
• Besides, executable files have different formats on different
computers, and different operating systems utilize different data
structures and algorithms for similar tasks.
• For those and other reasons, there is no way to write one program
that will run on dissimilar computing systems.
System Programming
System Programming

Application Programs System Programs


System Programming
System programs provide a convenient environment for program
development & execution. They are divided into the following
categories.
• File manipulation: These programs create, delete, copy, rename,
print & manipulate files and directories.
• Status information: Some programs ask the system for date, time
& amount of available memory or disk space, no. of users or
similar status information.
• File modification: Several text editors are available to create and
modify the contents of file stored on disk.
System Programming
• Programming language support: compliers, assemblers &
interpreters are provided to the user with the OS.
• Programming loading and execution: Once a program is assembled
or compiled, it must be loaded into memory to be executed.
• Communications: These programs provide the mechanism for
creating virtual connections among processes users 2nd different
computer systems.
• Application programs: Most OS are supplied with programs that are
useful to solve common problems or perform common operations. Ex:
web browsers, word processors & text formatters etc.
Kernel
The kernel is a computer program at the core of a computer's
operating system and generally has complete control over
everything in the system.
Or,
A kernel is a central component of an operating system that
manages the operations of computers and hardware.
• The main functions of a kernel include process management,
memory management, device management, and system calls
handling.
OS Design and Implementation
• Design Goals
• Choice of hardware
• Type of system
• Requirements
• User Goals ??
• Convenient, easy to use/learn, reliable, safe, fast etc.
• System Goals ??
• Easy to design, implement, operate, flexible, reliable, efficient etc.
• Mechanism and Policies
OS Design and Implementation
• Implementation
• Once an operating system is designed, it must be implemented.
• Traditionally, operating systems have been written in assembly
language.
• Now, however, they are most commonly written in higher-level
languages such as C or C++
OS Design and Implementation
• Advantage of OS(system programs) in HLL
• The code can be written faster
• It is more compact
• It is easier to understand and debug
• It is easier to port
• E.g.
• MS-DOS was written in Intel 8088 assembly language. Consequently, it is
available on only the Intel family of CPUs.
• The Linux operating system, in contrast, is written mostly in C and is available on
a number of different CPUs, including Intel 80X86, Motorola 680X0, SPARC, and
MIPS RXOOO.
Structure of OS
• Simple design
• E.g. MS-DOS
Structure of OS
• Monolithic
• E.g. Unix
• Speed and efficiency
• Single, static, binary
file that runs in a
single address
space.
• have some modular
design aspects, but
structural limitations
make them difficult
to implement and
modify.
Structure of OS
Layered Approach
• Implementation and modification easier, by designing
the operating system as a set of very distinct modules
called layers.
• Each layer is a well-defined abstract data structure
(aka, object) with specific data members and
operations (methods).
• The design of the layers requires that they be
numbered from lowest to highest, with the lowest
being the hardware, and the highest being the user
interface.
• Code in one layer, can make calls to functions in other
layers, but only if those functions are in the same or
lower layers.
Structure of OS
Layered Approach
• Because of the rules, once the system is designed, it's
relatively easy to build without errors, starting with the
hardware, and continuing with the next highest layer only
after the current layer has been implemented and tested.
• It can be quite difficult to design operating system layers
in a way that absolutely assures that a lower layer will
never need to use a function in a higher layer.
• Also, a command that originates in a higher layer can
result in a cascade of calls to functions in lower and
lower levels. If this travels through several layers, it can
cause delay, which tends to make the system slow and
inefficient.
• Many OS designs use the idea of layering, but, to protect
the efficiency of the system, there tend to be just a few
large layers, rather than many small layers.
Structure of OS
Microkernels
• Because of functionality to operating systems, it became
increasingly difficult to implement monolithic systems.
• Monolithic kernel is
replaced with a
microkernel that
provides just a few
essential services, and
the rest of the operating
system is turned into
separate user-level
programs.
Structure of OS
Microkernels
• Microkernels typically contain some core process and memory
management functions, as well as a message passing service.
• When a user program needs a service from the OS, it typically uses the
microkernel's message-passing service. The microkernel makes sure
that the request reaches the necessary part of the OS.
• Modular architectures: reliable, secure, maintain, modify, and port.
• Suffer performance problems: excessive time spent on message-
passing work.
• Because of such performance problems, designers tend to just use
some of the ideas of microkernel approach, without building 'pure'
microkernel systems.
Structure of OS
Modules
• “Modules” design involves using loadable kernel modules.
Structure of OS
Modules
• Modules are similar to layers in that each subsystem has clearly defined
tasks and interfaces, but any module is free to contact any other module,
eliminating the problems of going through multiple intermediary layers.
• The LKMs may be loaded at boot time, or loaded when needed while the
system is running. They can also be deleted from memory if no longer
needed.
• An example would be a device driver support module loaded when a new
device is plugged into the computer, and when the device is unplugged, the
module is deleted because it is not needed any more.
• 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.
Structure of OS
Hybrid Systems e.g., Mac OS X
• Mach micro-kernel and a BSD Unix kernel
implemented over the Mach micro-kernel
• Application services and dynamically
loadable modules ( kernel extensions )
provide the rest of the OS functionality
Structure of OS
Hybrid Systems e.g., Android
• Android is an open-source OS, as opposed to
iOS, which has lead to its popularity.
• Android includes versions of Linux and a Java
virtual machine both optimized for small
platforms.
• Android apps are developed using a special
Java-for-Android development environment.
Operating-System Generation
• Information that is needed to configure an OS include:
• What CPU(s) are installed on the system, and what optional characteristics
does each have?
• How much RAM is installed? ( This may be determined automatically, either
at install or boot time. )
• What devices are present? The OS needs to determine which device drivers to
include, as well as some device-specific characteristics and parameters.
• What OS options are desired, and what values to set for particular OS
parameters. The latter may include the size of the open file table, the number
of buffers to use, process scheduling ( priority ) parameters, disk scheduling
algorithms, number of slots in the process table, etc.
Operating-System Generation
• Systems have to be configured for the specific site to which they
are targeted. We perform system generation when we put a new
host online, providing at that time, for example, a hostname, host
IP address, router IP address.
• Other SYSGEN operations possible: disk partitioning, installation
of device drivers, choice of CPU-scheduling algorithm, and setting
of the maximum number of processes to be supported.
• The SYSGEN information may be incorporated into the source
code for the OS, and a custom version of the OS then compiled.
Operating-System Generation
• Another option, common in PCs, laptops, and mobile devices, is for the
system to be pre-compiled and the SYSGEN information saved in the
form of tabular information in files, accessed and utilized by the pre-
compiled OS in order to achieve the desired customization effects. For
example the system can read its hostname and default router from a
configuration file. Scripts written during the SYSGEN can be executed
each time the computer boots in order to perform custom setups.
• Tables can determine which of certain dynamically loadable modules
are to be loaded at boot time.
• SYSGEN may be followed by a linking, but not compiling step, so that
certain modules such as drivers are incorporated into a permanent
executable image of the kernel.
System Boot
• “Bootstrap" program located in ROM chips ( or EPROM chips ) on the
motherboard.
• ROM bootstrap program first runs hardware checks, determining what
physical resources are present and doing power-on self tests ( POST )
of all HW for which this is applicable. Some devices, such as controller
cards may have their own on-board diagnostics, which are called by
the ROM bootstrap program.
• The user generally has the option of pressing a special key during the
POST process, which will launch the ROM BIOS configuration utility if
pressed. This utility allows the user to specify and configure certain
hardware parameters as where to look for an OS and whether or not to
restrict access to the utility with a password.
System Boot
• Assuming the utility has not been invoked, the bootstrap program then
looks for a non-volatile storage device containing an OS.
• For a single-boot system, the boot program loaded off of the hard disk
will then proceed to locate the kernel on the hard drive, load the kernel
into memory, and then transfer control over to the kernel.
• For dual-boot or multiple-boot systems, the boot program will give the
user an opportunity to specify a particular OS to load, with a default
choice if the user does not pick a particular OS within a given time
frame. The boot program then finds the boot loader for the chosen
single-boot OS, and runs that program as described in the previous
bullet point.
Next Lecture
Process Management

You might also like