0% found this document useful (0 votes)
514 views37 pages

Computer Fundamentals and Programming in C: By: Pradip Dey & Manas Ghosh

Uploaded by

Varun Arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
514 views37 pages

Computer Fundamentals and Programming in C: By: Pradip Dey & Manas Ghosh

Uploaded by

Varun Arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 37

Computer

Fundamentals and
Programming in C

By: Pradip Dey & Manas


Ghosh

© Oxford University Press 2013. All rights reserved. 1


Basic Concepts of
Operating Systems
CHAPTER 5

© Oxford University Press 2013. All rights reserved. 2


Overview
 Explain the basic role of an operating system in
modern-day computers
 Explain the general functions and components of
an operating system
 Discuss the interfacing between the operating
system and application program or the user
 Trace the history of the development of
operating systems
 Explain the different types of operating systems
 Get an overview on some operating systems
such as unix and msdos

© Oxford University Press 2013. All rights reserved. 3


Key Words
 Resource: In the context of a computer system, it means memory or any
input / output device.

 Process: It is a program in execution.

 File: It is a data storage unit that holds information.

 System programs: These could be operating system, compilers, editors,


loaders, utilities, etc.

 Application programs: These are database systems, business programs, etc.

 Process management : These are jobs related to the unhindered execution


of programs.

 Memory management : An activity or a set of activities associated with


allocating and de-allocating memory space.

 I/O device: This refers to a proper activation and de-activation of input /


output device management with appropriate hardware and software.

© Oxford University Press 2013. All rights reserved. 4


Key Words
 File management: A set of jobs associated with creating,
retrieving, deleting, amending data storage units on storage
devices and keeping track of the same.
 Protection : It is the mechanism for controlling the access of
programs, in Operating System processes, or users to the
resources in the computer.
 Command interpreter: It a system program, which is an
essential component of the operating system, that accepts,
deciphers and executes the job related to the command
statement.
 Kernel : It is the core library of functions that provides the most
basic interface between the computer machine and the rest of
the operating system.
 System calls: It provides the interface between a running
program and the operating system.

© Oxford University Press 2013. All rights reserved. 5


Key Words
 Operating system commands : These are commands through
which the user interacts with the operating system directly.

 Batch processing :These are jobs that are executed with minimum
user interaction and as and when the computer system is available
following a schedule.

 Multiprogramming: Multi programming refers to the situation in


which a single CPU divides its time between more than one job.

 Multitasking :Multi tasking refers to execution of more than one


application program at any given time.

 Time-sharing :In the context of a computer, time-sharing means


sharing of the computer resources among many users by allocating
them for a specified time.

© Oxford University Press 2013. All rights reserved. 6


Key Words
 Multiprocessing :Any simultaneous execution of
multiple processes on different processors.
 Real-time: In the context of an operating system, it
is an operating system that provides quick and time
critical response.
 Networked computing :A collection of physically
interconnected computers.
 Distributed computing :This refers to processing of
computing jobs by automatically sharing the job-
processing load among the constituent computers
connected to the same network.

© Oxford University Press 2013. All rights reserved. 7


8

© Oxford University Press 2013. All rights reserved.


Introduction
 Without software, a computer is
basically a useless equipment.
With software, a computer can
store, process, and retrieve
information and engage in many
other valuable activities.

◦ Computer software can be divided


roughly into two parts: system
programs, which manage the
operation of the computer itself, and
application programs, which perform
the actual work the user wants.

◦ The most important system program


is the operating system (OS) that
controls all the computer resources
and provides the base upon which the
application program can be written.

© Oxford University Press 2013. All rights reserved. 9


Introduction : Operating
System
 An operating system is a collection of programs that acts as an
interface between the user of a computer and the computer
hardware.

◦ Without software, a modern-day computer is unusable. Software


comprising operating system, programming language compilers, etc.
are essential to provide an ‘user-friendly’ interface to the user.

 A n operating system is an important part of almost every


computer system that comprises three main components:

◦ The hardware (memory, CPU, arithmetic-logic unit, various storage


devices, I/O, peripheral devices, etc.)
◦ Systems programs (operating system, compilers, editors, loaders,
utilities, etc.)
◦ Application programs (database systems, business programs, etc.)

© Oxford University Press 2013. All rights reserved. 10


Functions of an Operating
System
 An operating system has the following functions:

◦ Process management
◦ Memory management
◦ Secondary memory management
◦ Device (I/O) management
◦ File management
◦ Protection

© Oxford University Press 2013. All rights reserved. 11


Components of an Operating
System
 In general there are two main
components of an operating system:
◦ command interpreter &
◦ Kernel
 Command interpreter
◦ Command interpreter is one of the most
important components of an operating
system. It is the primary interface
between the user and the rest of the
system.
 Kernel
◦ Kernel is a core part of the operating
system and is loaded on the main memory
when it starts up. It is the core library of
functions; the operating system ‘knows’.
◦ In the kernel, there are the functions and
streams to communicate with the system’s
hardware resources.

© Oxford University Press 2013. All rights reserved. 12


Interaction with Operating
System
 Broadly speaking, there are two ways to interact with an
operating system:
◦ By means of operating system calls in a program
◦ Directly by means of operating system commands

 System calls
◦ System calls provide the interface between a running program and the
operating system.
◦ These calls are generally available as assembly language instructions,
and are usually listed in the manuals used by assembly language
programmers.
◦ Some systems may allow system calls to be made directly from a high-
level language program, in which case the calls normally resemble
predefined function or subroutine calls.
◦ System calls can be roughly grouped into five major categories :
process control, file manipulation, device manipulation, information
maintenance, and communications.

© Oxford University Press 2013. All rights reserved. 13


Interaction with Operating
System
 Operating system commands

◦ Apart from system calls, users may interact with the


operating system directly by means of commands.
◦ For example, if the user wants to list files or sub-
directories in MSDOS, the DIR command is invoked.
◦ In either case, the operating system acts as an interface
between users and the hardware of a computer system.
◦ The fundamental goal of a computer system is to solve
user problems. The computer hardware is designed
towards this goal.
◦ The command function of controlling and allocating
resources are then brought together into one piece of
software, the operating system.

© Oxford University Press 2013. All rights reserved. 14


History of Operating Systems
 By tracing that evolution, the common elements of
operating systems can be identified as well as how and why
they developed as they are now.

◦ Operating systems and computer architecture have a great deal


of influence on each other. Operating systems were developed
to facilitate the use of the hardware.

◦ First Generation (1945–55)


◦ Second Generation (1956–63)—Transistors and Batch
System
◦ Third Generation (1964–80)—Integrated Chips and
Multiprogramming
◦ Fourth Generation (1980–present)— Personal Computers

© Oxford University Press 2013. All rights reserved. 15


Types of Operating Systems
 Modern computer operating systems may be classified into three
groups according to the nature of interaction that takes place
between the computer user and user’s program during its processing.

◦ The three groups are called batch process, time-shared, and real-time
operating systems.

 Batch Process Operating System

◦ In a batch process operating system, environment users submit jobs to a


central place where these jobs are collected in batch, and subsequently
placed in an input queue in the computer where they are run.

◦ Two major disadvantages and they are as follows:


 Non-interactive environment
 Offline debugging

© Oxford University Press 2013. All rights reserved. 16


Types of Operating
Systems
 Multiprogramming Operating System
◦ A multiprogramming operating system allows more than one
active user program (or part of user program) to be stored
in the main memory simultaneously.
◦ Compared to batch operating systems, multiprogramming
operating systems are fairly sophisticated.
 Multitasking operating systems
 Multi-user operating system
 Multiprocessing system

Time-sharing Operating Systems


◦ Another mode for delivering computing services is provided by
time-sharing operating systems.
◦ In this environment a computer provides computing services to
several or many users concurrently online.

© Oxford University Press 2013. All rights reserved. 17


Types of Operating Systems
 Real-time Operating Systems

◦ The fourth class of operating systems, real-time operating


systems, are designed to service those applications where
response time is of essence in order to prevent error,
misrepresentation, or even disaster.
 Memory management
 I/O management
 File management

 Network Operating System


◦ A networked computing system is a collection of physically
interconnected computers.
◦ The operating system of each of the interconnected computers must
contain, in addition to its own stand-alone functionality, provisions for
handling communication and transfer of program and data among the
other computers with which it is connected.

© Oxford University Press 2013. All rights reserved. 18


Types of Operating Systems
 Distributed Operating System

◦ A distributed computing system consists of a number of computers


that are connected and managed so that they automatically share
the job-processing load among the constituent computers, or
separate the job load, as appropriate, to particularly configured
processors.

 Advantages of distributed operating systems :

◦ Major breakthrough in microprocessor technology


◦ Incremental growth
◦ Reliability
◦ File system
◦ Protection
◦ Program execution

© Oxford University Press 2013. All rights reserved. 19


Overview of UNIX Operating
System
 UNIX is an operating system. It was created in
the late 1960s,in an effort to provide a multi-
user, multitasking system for use by
programmers.

 The philosophy behind the design of UNIX was


to provide simple, yet powerful utilities that
could be pieced together in a flexible manner to
perform a wide variety of tasks.

© Oxford University Press 2013. All rights reserved. 20


Reasons for Success of UNIX
 Duringthe past 30 years, UNIX has evolved into
a powerful, flexible, and versatile operating
system.

 It is used on

(a) single user personal computers,


(b) engineering workstations,
(c) multi-user microcomputers,
(d) minicomputers,
(e) mainframes, and
(f) Supercomputers

© Oxford University Press 2013. All rights reserved. 21


Features of Unix
 The reasons for this are the characteristics of UNIX, enumerated as follows:

 Portability:

◦ Because the UNIX operating system is written mostly in C, it is highly portable.


◦ It runs on a range of computers from microprocessors to the largest mainframe , provided the system
has two components: a C compiler, and a modest amount of machine-dependent coding (machine
dependent I/O hardware service routines).

 Open system :

◦ It easily adapts to particular requirements.


◦ This openness has led to the introduction of a wide range of new features and versions customized to
meet special needs. The code for UNIX is straightforward, modular, and compact.
◦ This has fostered the evolution of the UNIX system.

 Rich and productive programming environment :

◦ UNIX provides users with powerful tools and utilities. Some of these tools are simple commands that
can be used to carry out specific tasks.
◦ Other tools and utilities are really small programmable languages that may be used to build scripts to
solve problems.
◦ More importantly, the tools are intended to work together, like machine parts or building blocks.

© Oxford University Press 2013. All rights reserved. 22


Features of Unix
 Communication:

◦ The UNIX system provides an excellent environment for networking.


◦ It offers programs and utilities that provide the services needed to build
networked applications, the basis for distributed network computing.

 Multi-user capability:

◦ More than one user can access the same data at the same time.
◦ A computer system that can support multiple users is generally less expensive
than the equivalent number of single-user machines.

 Multitasking:

◦ A given user can perform more than one task at the same time. One could
update the client’s database while printing the monthly sales report.
◦ The limit is about 20 simultaneous tasks per user and depending on the
computer system, a system-wide limit of 50 or more tasks can be performed,
which slows the response.

© Oxford University Press 2013. All rights reserved. 23


Components of UNIX
 UNIX carries out various functions through three separate, but closely
integrated parts: kernel, command interpreter, and file system.
 Kernel : Known as the base operating system, kernel manages and
allocates resources, interacts with I/O devices, and controls access to
the processor. It controls the computer’s resources.
 In short, it provides the following functions:

◦ Process scheduling (process representation—structure, scheduling, and


dispatching)
◦ Memory management
◦ Device management
◦ File management
◦ System call interface
◦ Process synchronization and inter-process communication
◦ Operator console interface

© Oxford University Press 2013. All rights reserved. 24


© Oxford University Press 2013. All rights reserved. 25
Command Interpreter
 This is a utility program and is
called the shell. It interacts with
the user and translates the user’s
request into actions on the part of
the kernel and the other utility .
Each user opens one shell on
logging on.

 Different types of shells are


available such as Bourne shell, C
shell, and Korn shell.

◦ Protection of file data


◦ The treatment of peripheral devices
as files

26

© Oxford University Press 2013. All rights reserved.


The UNIX File System
 Thefile system is one of the major subsystems of
the operating system.

◦ It is responsible for storing information on disk drives


and retrieving and updating this information as directed
by the user or by a program.
◦ The UNIX operating system regards practically every
assemblage of information as a file. The formal definition
of a file is a string of characters.
◦ Often, it is desirable to organize UNIX files as a set of
lines. Every line is terminated by a new line character.

© Oxford University Press 2013. All rights reserved. 27


The UNIX File System
 The UNIX file system is characterized by the
following:

◦ A hierarchical structure
◦ Consistent treatment of file data
◦ The ability to create and delete files
◦ Dynamic growth of files

 Types of files: The UNIX system has the following


types of files:

◦ Ordinary files
◦ Directory files
◦ Special files

© Oxford University Press 2013. All rights reserved. 28


© Oxford University Press 2013. All rights reserved. 29
Example
 Problem :- Using a UNIX command, return to home directory.
 Solution:

◦ Cd..
◦ Issuing the cd command without any arguments moves the choice to the
home directory. This is very useful if the user is lost in the file system.

 The directories . and ..

◦ In UNIX, (.) means the current directory, so typing cd . means staying in


the current directory. While (..) means the parent of the current
directory, so typing cd .. will take the user one directory up the
hierarchy, that is, back to the user’s home directory.
◦ Note that there is a space between cd and the dot. Entering cd/ moves
the user to the root directory. / is the root directory.

© Oxford University Press 2013. All rights reserved. 30


Role of Disk Drive for Loading
DOS
A disk drive is a device that either stores data or
reads data from the disk, which may be a floppy or a
hard disk. A PC has floppy drives, hard disk drives,
and CD-ROM drives.

◦ The first floppy drive is conventionally called drive A


whereas the second floppy drive is designated as drive B
and the first hard disk drive is designated as drive C.
◦ Booting is synonymous with starting a computer. When the
computer is switched on, the BIOS program, fused in the
ROM, checks the memory and peripherals.

 The following prompt appears and awaits orders from


the user:
A:>_ or C:>_

© Oxford University Press 2013. All rights reserved. 31


Starting DOS
 When the computer starts working, it does not have an
ordinary program loaded into it. The computer does, however,
have two special built-in programs it can rely on, and it does
know how to do the following:
 How to do self-testing to see that things are in working order
 How to start up dos?

◦ This start-up program is usually called a bootstrap loader, since it pulls


dos up by the bootstraps.
◦ This bootstrap operation works in two stages.
◦ First, the tiny program built into the computer goes to work.
◦ It just knows how to read the beginning of a diskette or the hard disk,
in case the diskette is not used, and runs whatever it finds there as any
other operating system.

© Oxford University Press 2013. All rights reserved. 32


Starting DOS
◦ Second, the start-up program checks the memory. Then, it loads
the dos system files into the memory. There are three main
system files in dos. These are as follows:

IO.SYS
DOS.SYS
COMMAND.COM

 The primary memory of the personal computer is


subdivided into three parts.

◦ Conventional memory
◦ Extended memory
◦ Expanded memory

 Extended memory requires HIMEM.SYS to manage it.

© Oxford University Press 2013. All rights reserved. 33


The Command Prompt
 When the personal computer is turned on, some
cryptic information flashes by.
 MSDOS displays this information to let the user know
how it is configuring the computer. This can be
ignored now. When the display stops scrolling past
the information, the following is seen on the screen:
C:\>
 This is called the command prompt or dos prompt.
 Ifthe command prompt does not look like that shown
above, type the following at the command prompt,
and then press <Enter>: cd \

© Oxford University Press 2013. All rights reserved. 34


Navigating Disks
 A disk’s storage comprises several parts of which two
are covered here: directories & files.
 Directories are dos’ way of organizing the many files that
can be placed on disk.
 Every disk has at least one directory. This is referred to as
the ‘root’ directory.
 From the root directory of every disk the user is able to
directly or indirectly access every file on the disk. The root
directory can hold directories or files.
 Subsequent directories can also hold directories or files,
and so on.

© Oxford University Press 2013. All rights reserved. 35


Naming a File
 While newer versions of dos support longer filenames,
the standard dos filename format remains as follows: one to
eight letters for a name, one dot for a period, and three
letters for the extension. For example,

◦ PROGRAM.EXE
◦ DATA.DAT
◦ LETTER.DOC

 The extension to a file’s name allows files of similar type to


be grouped together.

 That is, all word processor files might have the extension
.DOC, while all picture files might have the extension .PIC

© Oxford University Press 2013. All rights reserved. 36


Pipelines
 When the user needs the output of one dos command as the input of another
command, dos provides a handy way to make this simple.

 Suppose there are two commands, ONE and TWO. ONE creates data that is
needed by the command TWO.

 The user can apply the redirection operator to do this.


◦ ONE > WORK
◦ TWO < WORK

 The first command writes its data into the WORK file and the second program
reads back from it.

◦ This is the basic function that dos accomplishes with pipelines.


◦ A pipeline is just an automatic way of doing what the user did with WORK, ONE, and
TWO.

 To create a pipeline command, just write the program names on the same
command line, separated by a vertical bar (|) that is the symbol for a pipeline.

© Oxford University Press 2013. All rights reserved. 37

You might also like