LINUX OPERATING SYSTEM - Study Mafia

Transcription

www.studymafia.orgASeminar reportOnLINUX OPERATING SYSTEMSubmitted in partial fulfillment of the requirement for the award of degreeof Bachelor of Technology in Computer ScienceSUBMITTED TO:www.studymafia.orgSUBMITTED BY:www.studymafia.org1

www.studymafia.orgAcknowledgementI would like to thank respected Mr . and Mr. .for giving me such a wonderfulopportunity to expand my knowledge for my own branch and giving me guidelines to present aseminar report. It helped me a lot to realize of what we study for.Secondly, I would like to thank my parents who patiently helped me as i went through my workand helped to modify and eliminate some of the irrelevant or un-necessary stuffs.Thirdly, I would like to thank my friends who helped me to make my work more organized andwell-stacked till the end.Next, I would thank Microsoft for developing such a wonderful tool like MS Word. It helped mywork a lot to remain error-free.Last but clearly not the least, I would thank The Almighty for giving me strength to complete myreport on time.2

www.studymafia.orgPrefaceI have made this report file on the topic LINUX OPERATING SYSTEM; I have tried my bestto elucidate all the relevant detail to the topic to be included in the report. While in the beginningI have tried to give a general view about this topic.My efforts and wholehearted co-corporation of each and everyone has ended on a successfulnote. I express my sincere gratitude to .who assisting me throughout the preparation ofthis topic. I thank him for providing me the reinforcement, confidence and most importantly thetrack for the topic whenever I needed it.3

www.studymafia.orgCONTENTS Introduction to OperatingSystem Linux Components Process Management Process Scheduling Conclusion REFERENCES4

www.studymafia.orgINTRODUCTIONAn Operating System is a program that acts as anIntermediatery between the user of a computer and thecomputer hardware. The purpose of an operating system is toprovide an environment in which a user can execute programs ina convenient and efficient manner. An Operating System is aprogram that manages the computer hardware. It also provides abasis for application programs.An Operating System is an important part of almostevery computer system. An amazing aspect of operating systemis how varied it is useful in accomplishing the tasks.Mainframe Operating System are designed primarilyto optimize utilization of hardware. Personal Operating SystemSupport complex games, business applications and everything inBetween. Handheld computer Operating System are designedto provide an environment in which a user can easily interfacewith computer to execute programs.CompilerAssemblerText EditorSystem and application programsOperating SystemComputer Hardware5

www.studymafia.orgLINUX OPERATING SYSTEMLINUX is modern , free operating system based on UNIXstandards. It has been designed to run efficiently andreliably on common PC hardware, it run also on a variety ofother platforms. It provides a programming interface anduser interface compatible with standard UNIX systems.A Complete Linux system includes manyComponents that were independently of Linux.The core Linux operating-system Kernel is entirely original,But it allows much existing free UNIX software to run,resulting in an entire UNIX-compatible operating systemfree from proprietary code.The Linux kernel is implemented as a traditionalmonolithic kernel for performance reasons, but it ismodular enough in design to allow most drivers to bedynamically loaded and unloaded at a run time.Linux is a multi-user system ,providing protectionbetween processes and running multiple processes accordingto a time-sharing scheduler.6

www.studymafia.orgInter-process communication is supported formessage queues ,semaphores and shared memory andBSD’s socket interface.Multiple networking protocols can be accessedsimultaneously through the socket interface.To the user, the file system appears as a hierarchicalDirectory tree that obeys UNIX semantics. Linux uses anabstraction layer to manage multiple different file system.Device-oriented network and virtual file systemsare supported. Device-oriented file-systems access diskstorage through two caches.The memory management system uses page sharingand copy-on-write to minimize the duplication of datashared by different processes. Pages are loaded on demandwhen they are first referenced, and are paged back out tobacking store according to an LFU algorithm if physicalmemory needs to be reclaimed.7

www.studymafia.orgLINUX COMPONENTSThe Linux System is composed of three main bodies of code Kernel System Libraries System UtilitiesKERNEL:-The Kernel is responsible for maintaining all theimportant abstractions of the Operating System.SYSTEM LIBRARIES:- The System Libraries define a set ofStandard set of functions through which applications can interactwith kernel and that implement much of the operating systemFunctionality that does not need the full privileges of kernel code.SYSTEM UTILITIES:- The System Utilities are programs thatPerform individual, specialized management tasks,includingVirtual Memory and processes.8

ityProgramsUserProcessesCompilersSystem Shared LibrariesLinux KernelLoadable Kernel ModulesThe Linux Kernel forms the core of the Linux Operating System.It provides all the functionality necessary to run processes and itprovides system services to give arbitrated and protected access to thehardware resources .The System Libraries provide many types of functionality .At the simplest level, they allow applications to make kernel systemservice requests.Making a system call involves transferring control from unprivilegeduser mode to privileged Kernel mode.The System Libraries may also provide more complex versions of thebasic system calls. The libraries provide routines that do notcorrespond to system calls at all, such as sorting algorithms,mathematical functions and string manipulation routines. The LinuxSystem includes a wide variety of user-mode programs- boot Systemutilities and User utilities. The System utilities include all the programsnecessary to initialize the system, to load kernel modules.9

www.studymafia.orgPROCESS MANAGEMENTA process is the basic context within which all-user requestedActivity is serviced within operating system. To becompatible with other UNIX systems, Linux must use aprocess model similar to those of other versions of UNIX.Linux operates differently from UNIX in a few key places.1: THE FORK/EXEV PROCESS MODEL2: PROCESSES AND THREADS1:THE FORK/EXEV PROCESS MODEL :-The basic principle of UNIX process managementis to separate two distinct operations: the creation of processesand the running of the new program. A new process iscreated by the FORK system call, and a new program is runafter a call to EXEV.These are two distinctly separate functions. A new processmay be created with FORK without a new program being runthe new sub-process simply continues to execute exactly thesame program that first , parent process was running.This model has the advantage of great simplicity.Rather than having to specify every detail of the environmentof a new program in the system call that runs that program.If a parent process wishes to modify the environment inwhich a new program is to be run, it can Fork and then stillrunning the original program in a child process , make anysystem call it requires to modify that child process beforefinally executing the new program.10

www.studymafia.orgBroadly , Process Properties fall into three groups :1: PROCESS IDENTITY2: PROCESS ENVIRONMENT3: PROCESS CONTEXT1: Process Identity :mainly of the following items:A process identity consists Process ID(PID) : Each process has a uniqueidentifier. PIDs are used to specify processes to theoperating system when an application makes a systemcall to signal, modify , or wait for another process.Additional identifier associate the process with aprocess group and login session. Credentials:Each process must have anassociated user-id and one or more group IDs thatdetermine the rights of a process to access systemresources and files. Personality :- Process personality are nottraditionally found on UNIX systems , but under Linuxeach process has an associated personality identifier thatcan modify slightly the semantics of certain systemcalls.The process group and session identifiers can bechanged if the process wants to start a new group or session.Its credentials can be changed, subject to appropriate securitychecks.11

www.studymafia.org2: PROCESS ENVIRONMENT:A processenvironment is inherited from its parent and is composed oftwo null-terminated vectors: The Argument Vector The Environment VectorThe Argument Vector simply lists the command-linearguments used to invoke the running program andconventionally starts with the name of the program itself.The Environment Vector is a list of “NAME VALUE”pairs that associates named environment variables witharbitrary textual values. The environment is not held inkernel memory, but is stored in the process’ own usermode address space as the first datum at the top of theprocess’ stack.The passing of environment variables from oneprocess to the next and inheriting of these variables by thechildren of the process ,provide flexible ways to passinformation to components of the user-mode systemsoftware.3: PROCESS CONTEXT :- The process identity andenvironment properties are usually setup when a process is created andnot changed until that process exists. Process context is the state of therunning program at any one time , it changes constantly.12

www.studymafia.orgScheduling Context :The most important part of the process context is itsscheduling context: the information that the scheduler needs tosuspend and restart the process. This information includes savedcopies of all the process’ registers. Floating point registers arestored separately and are restored only when needed , so thatprocesses that do not use floating-point arithmetic do not incurthe overhead of saving that state.A key part of the scheduling context is the process’ kernelstack: a separate area of kernel memory reserved for useexclusively by kernel-mode code. Accounting: The kernel maintains information about theresources currently being consumed by each process and thetotal resources consumed by the process in its entire lifetime so far. File Table : The file table is an array of pointers to kernelfile structures. While making file-I/O system calls ,processes refer to files by their index into this table. File-System Context : Whereas the file table lists theexisting open files, the file-system context applies torequests to open new files. Signal – Handler Table : UNIX systems can deliverasynchronous signals to a process in response to variousexternal events. The signal-handler table defines the routinein the process’ address space to be called when the specificsignals arrive. Virtual – Memory Context : The Virtual-memorycontext describes the full contents of a process’ privateaddress space.13

www.studymafia.orgPROCESSES AND THREADSMost modern operating systems support both processes andthreads. Processes represent the execution of single programs, whereasthreads represent separate , concurrent execution contexts within asingle process running a single program.Any two separate processes have their own independentaddress spaces, even if they are using shared memory to share some ofthe contents of their virtual memory. Threads can be implemented inseveral ways. A thread may be implemented in the operating system’skernel as an object owned by a process or it may be fully independententity. It cannot be implemented in the kernel at all – threads may beimplemented purely within application or library code with the help ofkernel-supplied timer interruptions.The Linux kernel deals simply with the difference betweenprocesses and threads : it uses exactly the same internal representationfor each. A thread is just a new process that happens to share the sameaddress space as its parent. The distinction between a process and athread is made only when a new thread is created by the CLONEsystem call. Whereas fork creates a new process that has its ownentirely new process context , clone creates a new process that has itsown identity but is allowed to share the data structure of its parent.This distinction can be accomplished because Linux doesnot hold process’ entire context with in the main process data structurerather it holds contexts with in independent sub contexts. The clonesystem call accepts an argument that tells it which sub contexts tocopy, and which to share, when it creates the new process.The POSIX working groups have defined a programminginterface , specified in the POSIX.1c standard , to allow applications torun multiple threads. The Linux system libraries support two separatemechanisms that implement this single standard in different ways.It also allows multiple threads to be executing kernel system callssimultaneously.14

www.studymafia.orgPROCESS SCHEDULINGScheduling is the job of allocating CPU time to performdifferent tasks within an operating system. Normally, wethink of scheduling as being the running and interrupting ofprocesses , but another aspect of scheduling is also importantto Linux : the running of the various kernel tasks. Kerneltasks that are requested by a running process and tasks thatexecute internally on behalf of a device driver.1: Kernel Synchronization2: Process Scheduling3: Symmetric Multiprocessing KERNEL SYNCHRONIZATION :- The way thatthe kernel schedules its own operations is fundamentallydifferent from the way that it does process scheduling. Arequest for kernel mode execution can occur in two ways. Arunning program may request an operating system service,either explicitly via a system call, or explicitly- for examplewhen a page fault occurs. Alternately a device driver maydeliver a hardware interrupt that causes the CPU to startexecuting a kernel-defined handler for that interrupt.The first part of Linux’s solution to this problem lies inmaking normal code non-preemptible. Usually when a timerinterrupt is received by the kernel, it invokes the processscheduler, potentially so that it can suspend execution of thecurrently running process and resume running another one.15

www.studymafia.orgOnce a piece of kernel code starts running, it cangurantee that it will be the only kernel code running until oneof the following action occurs: An Interrupt A Page Fault A Kernel code call to the scheduler itselfInterrupts are a problem only if they contain criticalsections themselves. Timer interrupts never directly cause aprocess re-scheduler; they just request that a reschedule beperformed later, so any incoming interrupts can not effect theexecution order of non-interrupt kernel code. Once theinterrupt service is finished, execution will simply return tothe same kernel code that was running when the interrupt wastaken.Page faults are a potential problem; if a Kernel routinetries to read/write to user memory, it may incur a page-faultthat requires disk I/O completed and the running process willbe suspended until the I/O completes. When the processbecomes run able again, it will continue to execute in kernelmode, continuing at the instruction after the call to thescheduler.Linux implements this architecture by separatinginterrupt service routines into two sections: the top half andthe bottom half. The Top Half is a normal interrupt serviceroutine, and runs with recursive interrupts disabled, interruptsof a higher priority may interrupt the routine, but interrupts ofthe same or lower priority are disabled. The Bottom Half of aservice routine is run, with all interrupts enabled, by aminiature scheduler that ensures that bottom halves neverinterrupts themselves. The Bottom Half scheduler is invokedautomatically whenever an interrupt service routine exists.16

www.studymafia.orgTop Half Interrupt handlersBottom Half Interrupt handlersKernel-system routine(not preemptible)User-Mode Programs(Preemptible) PROCESS SCHEDULING :Once the kernel has reached a rescheduling point –either a rescheduling interrupt has occurred or a running kernelprocess has blocked waiting for some wakeup signals-it mustdecide what process to run next. Linux has two separate processscheduling algorithms.1: TIME SHARING Algorithms for preemptive scheduling2: TIME SHARING Algorithms for real-time tasksPart of every process identity is a scheduling class, thatdefines which of these algorithms to apply to the process. Thescheduling classes used by Linux are defined in the POSIXstandard’s extensions for real-time computing.For time-sharing processes, Linux uses a prioritized,credit-based algorithm. Each process possesses a certain number ofscheduling credits, when a new task must be chosen to run, theprocess with the most credits is selected. Every time that a timeinterrupts occurs, the currently running process loses one credit,17

www.studymafia.orgwhen its credits reaches zero, it is suspended and another process ischosen. If no run able processes have any credits, then Linuxperforms a re-crediting operation, adding credits to every process inthe system, rather than to just the run-able ones, according to thefollowing rule:Credits (Credits /2) PriorityThis algorithm tends to mix two factors, the process’ history andpriority. The use of the process priority in calculating new creditsallows the priority of a process to be fine-tuned. Background batchjobs can be given a low priority, hence will receive a smallerpercentage of the CPU time than will smaller jobs that have higherpriorities.Linux’s real-time scheduling is simpler still. Linuximplements the two real-time scheduling classes required byPOSIX.1b: First come, First serve (FCFS) and Round-robin.Linux’s real-time scheduling is soft-rather than hard-real time. SYMMETRIC MULTIPROCESSING :The Linux 2.0 kernel was the first stable Linux kernel tosupport Symmetric Multiprocessor (SMP) hardware. Separateprocesses or threads can execute in parallel on separate processors.The implementation of SMP in this kernel imposes the restrictionthat only one processor at a time can be executing kernel-modecode. SMP uses a single kernel spin lock to enforce this rule. Thisspin lock does not pose a problem for computation-bound tasks, buttasks that involve a lot of kernel activity can become seriouslybottlenecked.The development kernel 2.3 seems to have completelyremoved the single-kernel spin lock.18

www.studymafia.orgCONCLUSIONThe Latest LINUX Operating System therefore arecently developed system which has proved the more convenientand efficient operating system from the processing point of viewand from the addition of latest soft-wares point of view. It has beenconsidered as consisting of an advance technology than WIN-98and Windows-XP.19

pedia.orgwww.studymafia.org20

The Linux Kernel forms the core of the Linux Operating System. It provides all the functionality necessary to run processes and it provides system services to give arbitrated and protected access to the hardware resources . The System Libraries provide many types of functionality . At the s