OS Self - Notes
OS Self - Notes
===================================================================================
====
-------------SHELL PROGRAMMING------------------------------
WHAT IS SHELL??
SHELL is a program which provides the interface between the user and an operating
system.
A shell is a command-line interpreter program that parses and sends commands to the
operating system. This program represents an operating system's interactive
interface and the kernel's outermost layer (or shell). It allows users and programs
to send signals and expose an operating system's low-level utilities.
2. C Shell (csh)
Bill Joy created it at the University of California at Berkeley. It incorporated
features such as aliases and command history. It includes helpful programming
features like built-in arithmetic and C-like expression syntaxThe prompt switches
to %, while the root prompt is #.
The main drawbacks of the C shell are:
Syntax inconsistencies.
No support for standard input/output (stdio) file handles or functions.
Not fully recursive, which limits complex command handling
4. KornShell (ksh)
It was written by David Korn at AT&T Bell Labs. It is a superset of the Bourne
shell. So it supports everything in the Bourne shell.It has interactive features.
It includes features like built-in arithmetic and C-like arrays, functions, and
string-manipulation facilities. It is faster than C shell. It is compatible with
script written for C shell.($ for a user and # for root)
7. Z Shell (zsh)
The Z shell (zsh) is a Unix shell created as an extension for the Bourne shell in
the early 1990s. The feature-rich shell borrows ideas from ksh and tcsh to create a
well-built and usable alternative.
The executable location is in /bin/zsh. The prompt is user@hostname location % for
regular users and hostname# for the root user. The Z shell is the default shell of
Kali Linux and Mac OS
----------------------------SHELL
VARIABLE--------------------------------------------
WILSCARD SYMBOLS
Asterisk (*) and question mark (?) are the two wildcard characters and ** to select
subdirectories
Both of these will match any character (including spaces, punctuation, and non-UTF
symbols). The asterisk matches any number of characters (including zero), and the
question mark matches exactly one character.
If you have a directory with files named myfile-1.txt, myfile-2.txt, and myfile-
3.txt, then you can match all three of these files with the wildcard expression
myfile-?.txt. This would exclude myfile-10.txt, though, as there is more than one
character in 10, so the single question mark wildcard would fail to match. If you
wanted both myfile-1.txt and myfile-10.txt to be matched, you would want to use
myfile-*.txt.
---------------------METACHARCHTER------------------------
Metacharacters: These are the special characters that are first interpreted by the
shell before passing the same to the command. They are also known as shell
wildcards.
---------------------------- PROCESSES
-----------------------------------------------
NON-PREEMPTIVE ---> we can not forcefully terminate this type of processes
PREEMPTIVE ---> Here we can pause existing process to execute other process
MULTI-PROCESSING --->
There are two types of multiprocesses
1] ASSYMETRIC MULTI PROCESSES
Here os treats one of the process as master/special process and allows task to
it then that task gets divided into smaller task to get that process done from
other processor
2] SYMMETRIC MULTI PROCESSES
here all the processes are considered to be @ same level and hense os schedules
task to each processes individually
All modern system are SMP based
PROCESS STATE-->
NEW STATE
READY STATE
RUNNING STATE
WAITING STATE
TERMINATED STATE
-----------------------------------------------------------------------------------
-------------------
PROCESS SCHEDULING
1] FCFS
2] SJF
3] RR
4] PRIORITY
-----------------------------------------------------------------------------------
What is paging?
Paging is a technique that eliminates the requirements of contiguous allocation of
main memory. In this, the main memory is divided into fixed-size blocks of physical
memory called frames. The size of a frame should be kept the same as that of a page
to maximize the main memory and avoid external fragmentation
What is Segmentation?
Segmentation is a technique that eliminates the requirements of contiguous
allocation of main memory. In this, the main memory is divided into variable-size
blocks of physical memory called segments. It is based on the way the programmer
follows to structure their programs. With segmented memory allocation, each job is
divided into several segments of different sizes, one for each module. Functions,
subroutines, stack, array, etc., are examples of such modules