Class Notes Text File
Class Notes Text File
Q. What is Computer?
- Computer is a hardware/machine/digital device can be used to perform many tasks efficiently &
accurately.
- Computer Hardware mainly contains: Processor, Memory Devices & IO Device
- as any user cannot directly interacts with computer hardware, hence there is need of some
interface beteen user & hardware, and to provide this interface is the job of an OS.
Q. What is a software?
- software is a collection of programs
Q. What is a Program?
- Program is a finite set of instructions written in any programming lanaguge
(i.e. either low level/high level) given to the machine to do specific task.
- there are 3 types of program:
1. "system programs": programs which are the part of an OS
e.g. loader, kernel, cpu scheduler, interrupt handler etc...
2. "application programs":
e.g. notepad, google chrome, firefox, calculator, MS Office, games, compiler etc....
- "assembler": it is an application program which converts an assembly language code into machine
lanaguge code i.e. in a binary format/object code.
e.g.
In Linux - "asm"
In Windows - "masm" - microsoft assembler
- "linker": it is an application program which links object code of your program with precompiled
object modules of library functions and creates final single executable code.
e.g. In Linux - Linker Program --> "ld" : link editor
- declarations of all library functions exists in header files, whereas definiotions of these functions
are exists in a lib folder in precompiled object module format.
- once executable code/file gets created we can run/execute it by either doubly clicking on its icon
or by means of giving coammnd
$./program.out (press eneter). $./a.out
In Windows : $.\a.exe
- Program is passive entity, whereas if any program want to becomes active it must be loaded into
the main memory/RAM i.e. it must becomes a process.
What is Process -> Running Program/ When a program gets loaded into the main memory it
becomes a process.
"loader": it is a system program (i.e. builtin program of an OS), which loads an executable file from
hard disk drive into the main memory.
- loader/OS is responsible for an execution of any program
"dispatcher": it is a system program (i.e. builtin program of an OS), which loads instructions & data
of program from the main memory onto the CPU.
Scenario-1:
Machine1 - Linux : program.c
Machine2 - Windows : program.c -> compile -> execute --> ?? YES
Feature of C -> "Portability": program written in C on one machine/platform can be compiled and
execute on any other machine/platform.
Scenario-2:
Machine1 - Linux : program.c -> compiler -> program (executable code)
Machine2 - Windows : program (executable code) -> run ??? NO
- program written in C and compiled on one machine/platform cannot be executed on any other
machine/platform.
- "loader": when we try to run a program, loader first verifies file format
if file format matches then only it checks magic number, and file format as well magic number both
matches then only it loads an executable code from hard disk drive into the main memory.
Why?
- "file format" of an executable in Linux is different than file format of an executable file in
Windows.
"file format": it is a specific way to store data & instructions of a program in an executable file.
- In Linux ELF file format divides an executable file logically into different sections, so that in each
section specific data can be kept.
//global vars
int n1;//uninitialied variable -> bss section
int n2 = 100;//initialied variable -> data section
User
----------
UI Programs
----------
OS
----------
Hardware
- as any user cannot directly interacts with an OS, hence an OS provides two types of interfaces for
user through programs only.
1. "CUI/CLI": Command User Interface/Command Line Interface
- in this type of interface, user can interacts with an OS by means of entring commands in a text
format through command line.
e.g. In Windows : "cmd.exe" is name of the program which provides command user interface.
In Linux: "shell"/"terminal" is name of the program which provides command user interface.
In MSDOS: "command.com"
Q. What is an OS?
- An OS is a "system software" (i.e. collection of system programs) which acts as an interface
between user and hardware.
- An OS also acts as interface between programs and hardware.
- As an OS allocates required resources like main memory, CPU time, io devices access etc... to all
running programs, an OS is also called as a "resource allocator".
- An OS not only controls an execution of all programs, it also controls hardware devices which
connected to the computer system, and hence an OS is called as a "control program".
- As an OS manages available limited resources among all running programs, hence an OS is also
called as a "resource manager".
+ Functions of OS:
Kernel Functionalities/Basic Minimal Functionalities - any OS must support these functionalities -
compulsory functionalities.
1. Process Management
2. Memory Management
3. CPU Scheduling
4. Hardware Abstraction
5. File & IO Management
----------------------------------------------------------------------------
Extra Utility Functionalities - Utility S/W - optional functionalities
6. Networking
7. User Interfacing
8. Proetction & Security
- "Intallation of an OS": to install an OS on computer machine, is nothing but to store programs of
an OS which are in a binary format onto the HDD.
- If any OS want to becomes active, then atleast one program i.e. kernel need to load into the main
memory from HDD, and the process to load kernel from HDD into the main memory is called as
"booting".
- Motherboard is present inside cabinet onto the PCB: (Printed Circuit Board)
- Onto the Motherboard different components are attached: like Processor/CPU
RAM, Cache Memory, ROM etc....
- Components which are onto the motherboard is referred core computer system.
- Devices which are connected to the motherboard externally through ports are called as "peripheral
devices/peripherals/external devices/io devices"
e.g. monitor, keyboard, hard disk drive, printer, projector etc...
- "bootable device": if any storage device (i.e. HDD/CD/PD/DVD etc...) contains one special
program called as "bootstrap program" in its first sector/boot sector (i.e. in its first 512 bytes), then
it is called as "bootable device", and if boot sector is empty then it is referred as "non-bootable".
2. "System Boot"
- step4: upon selction of bootable device as a HDD, then "bootlaoder program" exists in it gets
invoked, and this program displays list of names of operating systems installed on it, and user has to
select any one os from that list at a time.
- step5: upon selection of any one OS, bootstrap program of that OS gets invokes and it locates the
kernel and load it into the main memory from HDD.