Beruflich Dokumente
Kultur Dokumente
UNIX :-
• Unix Operating system was originally developed in the Bell Laboratories which was once
a part of telecommunications giant AT&T .
• UNIX has become a very powerful and popular multitasking and multiuser operating
system for a wide variety of hardware platforms.
• UNIX is case sensitive, it supports lower case.
• UNIX does not contain an un-erase option, or an undo option.
• UNIX has many same features as DOS but are given different names.
History Of UNIX and LINUX :-
✔ In 1969,Ken Thompson and Denis Ritchie wrote the first version of UNIX in
PDP7 assembler language.
✔ Around this time “C” was conceived by DENNIS RITCHIE and in 1973
Dennis Ritchie and Ken Thompson rewrote the entire UNIX kernel in C
breaking away the tradition of using the assembly language for the same.
✔ Many vendors such as IBM, SUN and others purchased this source code of
UNIX and developed their own versions of UNIX.
✔ In 1991 LINUS TORVELL’s developed such kernel and called it LINUX.
• UNIX is a trademark administered by The Open Group, and UNIX refers to a computer
operating system that conforms to a particular specification. Specification is mainly
concerned to the term POSIX(Portable Operating System Interface) developed by the
IEEE(Institute Of Electrical and Electronic Engineers).
• Many UNIX-like systems are commercially available such as IBM’s AIX,HP’s HP-UX and Sun’s
Solaris.
• Following are some of the characteristics shared by typical UNIX programs and systems :-
1. Simplicity : UNIX utilities are very simple and as a result, small and easy to
understand. KISS “Keep It Small and Simple”, technique followed by the UNIX.
2. Focus : In UNIX various utilities are concerned with the user needs only and as
per the demands of the user.
3. Reusable Components :
4. Filters : Many UNIX applications can be used as filters which means that the
input given to the application come out translated by these applications as the
output.
5. Open File Formats: UNIX programs use configuration files and data files which
are plain ASCII text or XML.
LINUX :-
Q: what is kernel?? Illustrate its functioning in UNIX environment.
Linux is a freely distributed implementation of the UNIX like kernel, a kernel is a core of the
operating system.
Linux was developed by the Linus Torvalds at the university of Helsinki, this development
started as an inspiration by the Andy Tanenbaum’s MINIX, a small UNIX like system.
• Linux is actually just a KERNEL which can easily be installed and later on various other
freely distributed software programs could also be installed to make a complete Linux
installation.
• Some of the most popular LINUX distributions under the Intel x86 family of processors are :
○ Red Hat Enterprise Linux.
○ Fedora – A community cousin of Red Hat.
○ Novell SUSE Linux, openSUSE variant.
○ Ubuntu Linux.
○ Slackware.
○ Gentoo.
○ Debian GNU/Linux.
Linux is compatible with POSIX("Portable Operating System Interface [for Unix]"), the first version
was LINUX KERNEL which became available in 1991.
File management, program management and user interaction are traditional features of OS but LINUX
adds 2 more features i.e. Multiuser & Multitasking.
BASIC COMPNENTS OF LINUX ARE ::::::
The KERNEL --- It is a core program that runs program and manages hardware
devices or resources.
The ENVIRONMENT --- It provides the interface to the user and receives the
commands from the user and sends those commands to the kernel for execution.
The FILE STRUCTURE --- A file structure organizes the way files are stored on a
storage device here files are organized into directories.
It is true that UNIX and its most of the applications were written in “C” language but “C” language is
not the only option available to the LINUX or UNIX programmers. Various languages available to the
LINUX programmer :
UNIX uses a simple colon (:) character to separate the entries in the path variable, rather than the
Semicolon(;) that MS-Dos in Windows use.
For Example :
/usr/local/bin : /bin : /usr/bin : . : /home/neil/bin : /usr/X11R6/bin
The above PATH variables contain entries from the standard program locations, the current
directory (.), auser’s home directory and the X window system.
Linux uses forward slash (/) to separate the directories rather than Windows which uses (\).
“CHARACTERISTICS OF LINUX” OR “FEATURES OF LINUX”
1. Multi-Tasking ::
Linux supports true pre-emptive multitasking. Linux supports multitasking and
all the processes run entirely independently of each other without caring other
processes.
2. Multi-User ::
Linux allows a number of users to work with the system at the same time.
Linux is a computer system that is able to concurrently and independently execute
several applications belonging to two or more users.
3. Multi-Processing ::
Linux runs onto a multi process environment, which means that the OS can
distribute several applications across several processors.
4. Architecture Independence ::
Linux runs on almost all platforms that are able to process bits and bytes. This
type of hardware independence is not achieved by any other Operating System.
5. Demand Load Executables ::
Only those parts of the program which are actually required in for the execution
are loaded into the memory. Whenever a new process is created using fork()
command memory is not required immediately, but instead the memory for the
parent process is used jointly by both processes.
6. PAGING ::
Despite the best effort to use physical memory efficiently, it may be so that the
memory may be fully occupied. LINUX looks for 4KB pages of memory which
can be freed. Pages whose content has been already stored on hard disk are all
discarded.
7. Dynamic CACHE For Hard disk :: Linux dynamically adjust the size of cache memory to
suit the current memory usage situation. If no memory is available at the given time,
the size of the memory is reduced and new memory is provided. Once the memory is
released the area of cache is increased.
8. Shared Libraries :: Libraries are collections of routines needed by a program for
processing data.
9. Memory Protected Mode :: Linux uses the processor’s memory protection mechanisms
to prevent the process from accessing memory allocated to the system kernel or other
processes.
10.Support For National Keyboards & Fonts ::
11. Different File Systems :: Linux supports a variety of file systems. Some of the file
systems supported by linux are – Ext2, Proc.
In linux the applications provided by the system are listed in the /usr/bin, and the applications added
by the system administrators for a specific host computer or a local network are found in
/usr/local/bin or /opt.
Functions of an editor =
1. CREATING A FILE = Creating up of a file is done through an editor, writing up of data and later
storing the same anywhere as per the need is in a storage media.
2. OPENING AN EXISTING FILE = Editor allows to open an existing file with the changes made to
be saved, Multiple files are also meant to be opened.
3. COPYING AND PASTING TEXT= It should allow us to copy and paste because this facilitates
document creation.
4. SEARCHING FOR A TEXT =
5. HANDLING LARGE AMOUNT OF DATA =
Q : Define the system calls getpid, nice, pause, fork, execve, exit, wait.
A: SYSTEM CALL = The system call are part o kernel, the system call interface is an example of an
APPLICATION PROGRAMMING INTERFACE (API). An API is a set of system calls with strictly defined
parameter which allows an application request access to a service. System calls are totally different
to the library functions because all system calls can interact directly with hardware but any shell
command cannot interact with hardware.
Basically 3 steps are involved in each of process :
1. Fork() – Process creates a copy of the process that invokes it.
2. Exec() - This system call overlays a process by a further process whose name is the argument
of exec().
3. The 3rd stage is the wait() , it makes the parent process to wait for the child process to exit.
• getpid The getpid call is a very simple call, it merely reads a value from the task
structure and returns it.
• nice The system call nice is a little more complicated, nice expects as argument a
number by which the static priority of the current process is to be modified.
• pause A call to pause interrupts the execution of the program until the process is
reactivated by a signal. This merely amounts to setting the status of current process to
TASK_INTERRUPTABLE and then calling the scheduler.
• fork The system call fork is the only way of starting a new process. This is done by
creating an identical copy of the process that has called the fork. Fork is a very demanding
system call. All the data of the process have to be copied , and these can easily run to a
few megabytes.
• execve This system call enables a process to change its executing program, Linux
supports a number of executable files. Linux supports the widely used executable files
COFF (Common Object File Format) and ELF (Executable and Linkable Format).
• exit A process is always terminated by this kernel function call. It merely has to release
the resources that have been claimed up by the process and if necessary inform other
processes.
• wait The system call wait enables a process to wait for the end of a child process and
interrogate the exit code supplied. Depending on the argument given wait call will wait for
the specified child process.
Q: What is links ? What is the difference between Hard Links & Symbolic Links ?
A:
If a file is meant to be referred with the different different file names to access it from different
directories then the link of the same file is created with the help of the ln command.
$ ln original-file-name link-name
Hard Links & Symbolic Links :
Link within one disk and one user environment is called Hard Links. A hard link may in some
situations fall when you try to link to a file on some other user’s directory. A file in one file system
cannot be linked to a file in another file system.
To resolve this problem symbolic links are used, a symbolic link holds the pathname of the file to
which it is linking.
With a symbolic link we may link to a file on another user’s directory that is located on another file
system.
INTERRUPT : The use of interrupts is only possible if these are supported up by the hardware. Here,
the device informs the CPU via an interrupt channel (IRQ) that it has finished an operation.
For Ex. In the serial mouse, every movement of it sends data to the serial port, triggering an IRQ. The
data from the serial port is read first by handling ISR, which passes it through to the application
program.
INTERRUPT SHARING : Various hardware use the same IRQ number, if different hardware which used
same interrupt are used in same PCI board then the hardware conflict each other. In this case
interrupt sharing provides facility to use both device in same PCI board. For this if one device is used
the PCI buses the second device wait for freeing that buses.
BOTTOM HALVES :
TASK QUEUES : Task Queue is a dynamic extension of the concept of bottom halves, Use of bottom
halves is somewhat difficult because their number is limited to only 32, and some tasks are already
assigned to fixed numbers. Task queue allow a number of functions to be entered in a queue and
processor one after another at later time.
Before a function can be entered in a task queue, a tq_struct structure must be created and
initialized.
DMA mode : Direct Memory Access or DMA, is the hardware mechanism that allows peripheral
components to transfer their I/O data directly to and from main memory without the need for the
system processor to be involved in the transfer . Use of this mode is ideal for multitasking, as the
CPU can take care of other tasks during the data transfer.
In a DMA operation the data transfer takes place without CPU intervention the data bus is directly
driven by the I/O device and the DMAC(Direct Memory Access Controller)
setup() : The setup function must initialize the hardware devices in the computer and set up the
environment for the execution of the kernel program. Although the BIOS has already initialized most
hardware devices. It is desirable to pass parameters to a device driver or to the Linux kernel in
general. These parameters will come in the form of a command line from the LInux LOader(LILO).
Init() The init() function is only called during kernel initialization, but is responsible for important
tasks. This function tests for the presence of a device, generates internal device driver structures
and registers the device.
The call to the init() function must be carried out in one of the following functions, depending on the
type of device driver.
For
Character Devices : chr_dev_init()
Block Devices : blk_dev_init()
SCSI Devices : scsi_dev_init()
Network Devices : net_dev_init()
The init() function is also the right place to test whether a device supported by the driver present at
all, this applies especially for devices which cannot be connected or changed during operation, such
as hard disks.
Open() The open function is responsible for administering all the devices and is called as soon as a
process opens a device file. If only one process can work with a given device. When a device can be
used by a number of processes at the same time, open() should set up the necessary wait queues.
Release() The release function is only used when the file descriptor for the device is released. The
tasks of this function comprise a cleaning-up activities global in nature, such as clearing wait queues.
For some devices it can also be useful to pass through to the device all the data still in the
buffers.
Read() & Write() The read() and Write() functions perform a similar task that is copying data from
and to application code. Whenever an input device is used read() function is fired and for output
devices write() function fired, because only read operation is possible by input device like mouse,
keyboard and also write operation is possible by output devices like printer, monitor.
IOCTL() Each device has its own characteristics, which may consist in different operation modes
and certain basic settings. It may also be that device parameters such as IRQ’s, I/O addresses and so
on need to be set at run-time. IOCTL usually only change variables global to the driver or global
device settings.
Select() The select() function checks whether data can be read from the device or written to it, if
the device is free or argument wait is NULL, the device will only be check .
If it is ready for the function concerned, select() will return 1, otherwise a 0. If wait is not NULL, the
process must be held up until the device becomes available.
tilde (~) is the notation used for getting straight upto the HOME directory. For another user typing up
of “ ~ user ” will fetch the result.
The /home directory is itself a subdirectory of the root directory, / , which sits at the top of the
directory of the hierarchy and contains all the system’s files and folders.
The THREE device files found in both UNIX and LINUX are /dev/console , /dev/tty and /dev/null .
1. /dev/console :- This device represents the system console, Error messages and diagnostics
are often sent to this device. Each UNIX system has a designated terminal to receive the
console messages.
2. /dev/tty :- This special file is mainly for controlling terminal of a process.
3. /dev/null :- Unwanted output is redirected to this device.
System Calls And Device Drivers :: The files and devices can be accessed using a small number of
functions. These functions are known as system calls. At the heart of the operating system, the
KERNEL, are a number of device drivers. The low-level functions used to access the device drivers,
the system calls, include :-
• open : Open a file or device.
• read : Read from an open file.
• write : Write to a file or device.
• close : Close the file or a device.
• ioctl : Pass control information to a device driver such as any information related to input or
output. Each driver has its own set of input output commands.
UTILITIES ::: Linux programs and sources are commonly distributed in a file whose name contains
the version number , with an extension of .tar.gz or .tgz. These are gzipped TAR(TAPE ARCHIVE)
files also known as “TARBALLS”.
$ tar –cvf filename.tar “files tobe tarred”
Now so as to make it smaller or more compressed we may use a compression program ::::: i.e
gzip….
$ mv filename.tar.gz filename.tgz
Now to retrieve the files from the .tar.gz compression we can do following ::
$ mv filename.tgz filename.tar.gz
$ gzip -d filename.tar.gz
Each RPM package is stored in a file with an .rpm extension. Package files usually follow a naming
convention with the following structure :
Name-version-release.architecture.rpm
KERNEL ARCHITECTURE:::::::::
Most UNIX kernels are monolithic, each kernel layer is integrated into the whole kernel program and
runs in KERNEL mode on behalf of the current process Microkernel operating systems demand a very
smallest function from the kernel generally including a simple scheduler and an inter process
communication mechanism.
• Although Microkernels oriented Operating System are generally slower than the monolithic
ones.
• Linux was not designed on the drawing board but developed in an evolutionary manner and
continues to develop today.
• Each and every function of the kernel has been altered and expanded again and again to get
rid of the BUGS.
• The actual KERNEL provides only the necessary functionality like IPC(Inter Process
Communication) and MM(Memory Management).
• KERNEL is the Heart of the LINUX and basic functions of KERNEL are :
I/O Management
Process Management
Memory Management
File Management
USER
SHELL APPLICATION
LINUX KERNEL
Computer HARDWARE
LINUX SHELL ----
• Computer understands the language of )’s and 1’s called BINARY language, in early
days the commands to any of the computer system was given through this language
but it became very difficult for the people to give long commands and even to read &
write. So in Operating System there is a special program called SHELL which acts as an
interpreter between the KERNEL and the USER.
• SHELL is a command line interpreter that executes command read from the standard
input device or from a file.
• SHELL is not a part of KERNEL but uses the same for execution of the programs, create
files etc.
• Several SHELL’S AVAILABLE IN LINUX ARE :::
1. BASH(Bourne Again Shell) – It is most common shell.
2. CSH(C-Shell) – Language is similar to C language.
3. KSH(Korn Shell) –
4. TCSH
5. COMMAND.COM ----- SHELL name in MS-Dos but not a powerful one.
Normally the shells are interactive which means that shell accepts commands from
the user and executes them, but if all the commands are stored in a file and the
shell is told to execute the same file instead of entering the commands again and
again this is known as SHELL SCRIPT.
SHELL SCRIPTS :-
• If we have a sequence of linux commands that are used frequently, we can store them in a
file. It is then possible to have the shell read the file and execute the commands init and such
a file is called SCRIPT.
• A shell script allows input, output manipulation variables and a powerful flow of control and
iteration constructs for programming.
Numerous shell scripts are loaded into the system by default in the folder /etc/rc.d all these files are
useful in the booting up of the system.
A shell is basically a program that acts as the interface between the user and the Linux system,
enabling the user to enter those commands which are required by the user to be run or executed by
the user. A linux shell resembles to the Windows command prompt but they are more useful than the
latter. On linux it’s quite feasible to have multiple shells for various users.
In linux the standard shell that is always installed is the /bin/sh and is called bash (the GNU Bourne-
Again SHell) from the GNU suite of tools.
Version of bash can be checked by the following command :-
/bin/bash –version
Whenever a user is created we can assign a respective Shell to the same from the GNU mode, by
simply creating a user from the user manager.
Block Device ::
Block special files or Block device files or Block devices correspond to devices through which the
system moves data in the form of blocks. Linux makes use of dynamic cache system which employs
primary memory left unused by the kernel and the processes as buffer for block devices.
Some important data structures used by the BLOCK DEVICE layer are –
a) GenDisk :-
b) hd_struct :- This stores the information about a partition on the disk.
c) block_device :-
d) buffer_head :-
e) bio :-
f) bio_jeev :-
SHELL UTILITIES
APPLICATIONS
HARDWARE
1). “Kernel” :: The core of a linux system is kernel, and the same controls the
resources of the computer allocating them to different users & tasks. It
makes it easier for the programs to making interaction with the hardware
platforms. However the user does not interact directly with the KERNEL, an
interactive program is used up called “SHELL”.
2). “SHELL” :: Linux has a simple user interface and provides the same services
that a user demands. It is through the shell that the user interacts with the
hardware and also is not required to have the details of the hardware’s
internal. Some of the common shells used are :-
These are the set of those programs that are required by the user on day to day
basis and these programs are invoked in by their respective shells.
• INFORMATION COMMANDS –
○ LEARN = SELF LEARNING INSTRUCTIONS ABOUT LINUX.
○ APROPOS =
○ MAN = THIS COMMAND GIVES THE DETAILED INFORMATION ABOUT VARIOUS COMMANDS AND THEIR
USAGE.
• PROCESS MANAGEMENT –
○ PS = THIS COMMAND PRINTS THE STATUS OF VARIOUS PROCESSES.
○ KILL = THIS COMMAND IS USED TO TERMINATE OR EVEN CANCEL A PROCESS.
○ WAIT = THIS COMMAND WAITS FOR THE BACKGROUND PROCESSES.
○ SLEEP =
○ BATCH = THIS COMMANDS EXECUTES THE PROCESSES.
DEBUGGING COMMANDS –
MEMORY ADDRESS :
Programmers casually refer to a memory address as a way to access the memory cells. In
x86 Micro processors, we have three kinds of memory addresses –
1. Logical Addresses – This is an address which is included in the machine language
instructions to specify the address of an instruction. Each logical addresses
consists of a segment and an offset that denotes the distance from the start of the
segment to the actual address.
2. Linear Addresses – This address includes a single 32 bit insigned integer that can
be used to address upto 4GB that is upto 2 3 2 memory cells. Linear addresses are
usually represented in hexe-decimal notation. Their values ranges from
0x00000000 to 0xffffffff.
3. Physical Addresses – Physical addresses is used to address memory cells included
in memory chips. They correspond to the electrical signals sent along the address
pins of the microprocessor to the memory bus. Physical Address are represented as
32bit unsigned integer.
Access to the user segment can be made using the put_user() and get_user() functions
mentioned earlier.
When a monitored events occurs, the traced program is stopped and a SIGCHLD signal is sent to its
parent. When the parent wishes to resume the child’s execution, it can use one of the PTRACE_CONT.
Debuggers such as gdb are based on ptrace() system call. Since, ptrace() system call is dependent
on the process architecture, this call is defined in the file arch/i836/Kernel/ptrace.C.
Ptrace() system call, can be called through function –
long ptrace(enum_ptrace_request request, pid_t pid, void *addr, void *data)
------------------------------------------------------------------------------------
----
BUFFER
Device
➢ Each file system starts with a BOOT block. This block is reserved for the code required to
boot the operating system.
➢ As file system should usually be able to exist on any block oriented device and on each device
in principle they will always have the same structure, the boot block will be present whether or
not the computer is booted from the device.
➢ All the information which is essential for managing the file system is held in the superblock.
➢ This is followed by a number of inode blocks containing the inode structures for the file
system.
➢ The remaining blocks for the device provide the space for the data.
➢ These data blocks thus contain ordinary files along with the directory entries and the indirect
blocks.
The file system is the most visible aspect of an operating system, it provides the mechanism for
online storage of and access to both data and programs of the operating system.
• Each file system starts with a boot block, which is required to boot the Operating System.
• The range of the file system supported is made possible by the unified interface to the Linux
Kernel, and is the Virtual File System Switch(VFS). VFS is a kernel software layer that handles
all the system calls related to a standard Linux file system and its main strength is providing a
common interface to several kinds of file systems.
• Common file model consists of the following structure types :
1) MOUNTING
2) The Superblock Structure
3) The inode structure
4) The file structure
Mounting :
➢ Before a file can be accessed the file system containing the file must be mounted.
➢ Mounting up of the file system can be easily done by either the system call mount or the
function mount_root().
➢ Mount command or the function both are run under the system call setup which gets called
just once after the init() process is created by the kernel function init().
➢ Every mounted file system is represented up by a super_block structure,
The File Structure : In a multitasking system two problems often arises that a number of processes
wish to access a file at the same time both read and to write. Even a single process may be reading
and writing at different points in the file.
The file structure describes how a process interacts with a file it has opened. Some operations on file
structure are :
Lseek() --- The job of this function is of positioning within a file.
Read() --- This function copies count bytes from the file into the buffer in the user address
space.
Write() ---
Select() --- This function checks that whether data can be read from a file or written to one.
Ioctl() --- This function sets the device specific parameters.
As LINUX was initially developed under MINIX, MINIX was the first LINUX file system and restricted
the partitions to the maximum of 64MB and filenames to no more than 14 characters, and hence the
search for a better file system started and the result was Ext file system – the first to be designed for
the Linux. The Ext file system allowed partitions up to 2GB and filenames up to 255 characters, this
file system included several significant extensions but offered unsatisfactory performance. At this
time the second Extended File system was introduced Ext2 in 1994, this was efficient as well as
robust.
Significant features of Ext2 are ::
1) Block Fragmentation :: System administrators usually choose large block sizes for accessing
recent disks, as a result small files stored in large blocks waste a lot of disk space, and This
problem has been solved by allowing several files to be stored in different fragments of the
same box.
2) Access Control Lists :: Instead of classifying the users of a file under three classes – Owner,
Group and others, an ACCESS CONTROL LIST(ACL) is associated with each file to specify the
access rights for any specific users or a combination of users.
3) Handling Of Encrypted and Compressed Files :: This file system included a new option which
can be specified while creating a file and will allow users to store compressed or encrypted
versions of the file on the disk.
4) Logical Deletion :: An undelete option used by the users to easily recover the data if needed
in between the work.
An Ext2 disk superblock is stored in an ext2_super_block structure, which contains the number of
inodes, file system size in blocks, number of reserved blocks, free blocks counter, free inodes
counter, block size, fragmented size and various other information.
DEBUGGING :- Debugging is the process in which a process is searched for errors and if the same
occurs at the run time the error is rectified or a warning is given. For the debugging purpose the
program will be loaded into a debugger such as gdb and run step by step until am error is found, this
includes real time applications, parallel processes and software which runs without a host Operating
System. The most common debugging technique is MONITORING. According to SEI (Software
Engineering Institute) and the IEEE, every significant piece of software will initially contain defects,
typically around 2 per 100 lines of code.
Types Of Errors ----
A bug usually arises from a small number of causes, each of suggests a specific method of
detection and removal :
• SPECIFICATIION ERRORS
• DESIGN ERRORS
• CODING ERRORS
One of the debugger is printk debugger and in the same the code is checked and on the occurrence
of an error an appropriate alarm message is given. For Ex. Whenever a kernel segment process to
call the data and code of user segment process, verify_area() function is fired, which checks all the
area of the code and if any error is occurred then printk debugger is called.
UNIT – IV (MULTIPROCESSING)
Multiprocessing was originated in mid 1950’s at a number of companies. In some early 1960’s
Burroughs Corporation introduced a symmetric MIMD(MULTIPLE INSTRUCTION MULTIPLE DATA)
multiprocessor with 4 CPU’s and upto 16 memory modules connected via a crossbar switch.
While multiprocessing systems were developed technologies also advanced the ability to shrink the
processor and operate at much higher clock rates.
One of the cheaper ways to improve hardware performance is to put more than one C.P.U on the
board. This can be done either by making the different CPU’s take on different jobs known as
ASYMMETRICAL MULTIPROCESSING or by making them all run in parallel doing the same job known
as SYMMETRICAL MULTIPROCESSING(smp).
In a multiprocessor system one processor is chosen up by the BIOS, it is called BSP(Boot Processor)
and is used basically for the system initialization . All the other processors are called AP(Application
Processors) and are initially halted up by the BIOS.
Doing asymmetrical multiprocessing effectively requires specialized knowledge about the task the
computer should do, which is available in a general purpose operating system such as LINUX. On the
other hand symmetric multiprocessing is easy to implement.
Symmetric Multi-Processing :::: Most of the systems are single processor systems, i.e they have only
one CPU. But sometimes the applications require more power from the processors, to solve such a
situation multiple processors are used for close communication, sharing the computer bus, the clock
and sometimes memory and peripheral devices. The most common technique used for
accomplishing such a multiprocessor system is SMP and in this same each processor runs an
identical copy of the operating system and they communicate with one another as needed.
In a symmetrical multiprocessing environment the CPU’s share the same memory and as a result,
code running on one CPU can affect the memory used by another. We can no longer be certain that a
variable we have set to a certain value in the previous line still has that value, the other CPU might
have played with it while we weren’t looking.
A Symmetric Multiprocessing architecture is simply one where two or more identical processors
connect to one another through a shared memory. Each processor has a equal access to the shared
memory.
BSP AP
CPU 1 CPU 2
Local Local
APIC 1 APIC 2
ICC bus
I/O APIC
In the development of multi-processor LINUX kernel’s was meant to have the following three rules :::
1. No process running in the kernel mode is meant to be interrupted by any other process which
is also running in the kernel mode, except when it releases control and sleeps.
2. Interrupt Handling can interrupt a process running in kernel mode but than in the end the
control is returned back to the same process. A process can even block the interrupts and
make sure that it will not be interrupted.
3. Interrupt handling cannot be interrupted up by the process running in the kernel mode. This
means that the interrupt handling will be processed completely or at the most be interrupted
by another interrupt of higher priority.
All processes to monitor the transition to the kernel mode use one single semaphore, this
semaphore is used to ensure that no process running in kernel mode can be interrupted up by
another process.
SPOOLING ::::
NETWORK IMPLEMENTATION
SOCKET STRUCTURE :::
Sockets are used to handle communication links between application over the network .
Communication between the client and the server is through the socket . The socket programming
interface provides for communication via a network as well as locally on a single computer. The
client socket sends a request for server socket, server socket receive this request and send an
acknowledge for client, client receive this ACK and send a concluding ACK for server. Now connection
is established.
TCP (Transmission Control Protocol) : The TCP provides full transport layer services to
applications, TCP is a pot-to-port protocol. TCP is a connection oriented protocol which means
that connection must be established in between both ends of the transmission, before either
may transmit data. By creating this connection TCP generates a virtual circuit between sender
and receiver that is active for a duration of transmission.
In a TCP connection, client uses the function connect() to set up a connection to the
server.
The function sends a SYN to the server and then goes over to the SYN_SENT state.
The process now blocked until it receives the SYN/ACK from the server.
Server receives the SYN by the listen() function and send a SYN/ACK for the client.
Client receives the SYN and again send a concluding ACK, and the connection is
established.
By calling the close() function client sends a FIN to the server, Server receives this FIN
and in return sends the ACK to the client and now the connection is terminated.
UDP( User Datagram Protocol) : UDP is not at all reliable and is hence used when there
is very less data to be transmitted, within a less distance. In UDP there is no guarantee that a
data packet sent will reach its destination. If the network traffic is high or the receiving
program is handling multiple requests from other programs, there is a chance of datagram
packet being lost. The UDP protocol does not make the use of a checksum mandatory, it
doesnot have an ability to specify which packet has been lost.
RARP (REVERSE ARP) : Linux can convert Ethernet addresses into IP addresses. A further
facility offered by Linux ‘proxy’ ARP, this enables subnetworks which should really be directly
interconnected by the hardware to be separated.
SHELL PROGRAMS
Q : WAP to get two values from the user and find the greatest one.
A:
echo “Enter the first Number”
read a
echo “Enter the second Number”
read b
if [$a –gt $b] then
echo “ A is greater than B”
else
echo “B is greater than A”
fi
Q : WAP to enter a username & validate the same from the database & verifying the
same.
A:
echo “Enter your Username”
read username
if [ “$username” = “vipul”]
then
echo “Success !!! You are now logged in”
else
echo “Sorry, wrong username.”
Fi
Q: WAP to accept any 3 numbers from the command line and print the largest number.
A:
Q: WAP which informs as soon as a specified user whose name is given along the
command line is logged into the system.
A:
Q: WAP which takes a source file name along the command line and duplicate file names
along the command lines and copies me the contents of source file from the destination
file.
A:
Q: