system programming.pptx

61
System Programming Lecture-1 Background Computer Architecture + Operating System

Upload: muhammedyeshaw

Post on 24-Sep-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

System Programming

System ProgrammingLecture-1BackgroundComputer Architecture + Operating SystemIntroductionComputer Systems Consist of HardwareSoftwareDataUserSoftware consists of System SoftwaresApplication Softwares

IntroductionSystem Software includesOperating systemsCommand line interfaceUNIXDOSGraphical User interfaceMacOS Windows

IntroductionSystem Software includesLanguage TranslatorsAssemblerCompilerInterpreterMacro Processor

IntroductionLanguage Translation Flow

Program CodingCompileProblem DefinitionLibraryLinkerObject File*.OBJExecution file*.exeIntroductionService ProgramsLoader and LinkerText EditorDebuggerData Base Management Systems (DBMS)

IntroductionWhat is System programming ?Software can be roughly divided into systems software and applications software.with practitioners called systems programmers and application programmers, respectively.IntroductionApplications Software:Deals with abstractions like customers, products, orders, balance sheets, employees, and players in a game.Solves problems of interest to humans, usually in application areas like health care, game playing, finance...Concerned with anything high-levelIntroductionApplications Software Is almost always device or platform independent; programs concentrate on general-purpose algorithms Is often done in languages like Java, C#, Perl, Python, Ruby, Lisp. JavaScript, or ML, that feature automatic garbage collection and free the programmer from low-level worries Is done in languages that generally have big fat runtime systems IntroductionSystems Software Deals with concepts extremely close to the hardware level, like registers and memory locations. Controls and manages computer systems Concerned with data transfer, reading from and writing to files, compiling, linking, loading, starting and stopping programs, and even fiddling with the individual bits of a small word of memory IntroductionSystems Software Deals with writing device drivers and operating systems, or at least directly using them; programmers exploit this low-level knowledge Is often done in assembly language and C, where programmers have to manage memory themselves.What is Systems Programming? Computer programming can be categorized into two categories .i.e.

What is Systems Programming? While designing software the programmer maydetermine the required inputs for that program,the wanted outputs and the processing the software would perform in order to give those wanted outputs.The implementation of the processing part is associated with application programming.

What is Systems Programming? Application programming facilitates the implementation of the required processing that software is supposed to perform; everything that is left now is facilitated by system programming.Systems programming is the study of techniques that facilitate the acquisition of data from input devices, these techniques also facilitates the output of data which may be the result of processing performed by an application. Three Layered Approach A system programmer may use a three layered approach for systems programming.As you can see in the figure the user may directly access the programmable hardware in order to perform I/O operations.use the trivial BIOS (Basic Input Output System) routines in order to perform I/Oin which case the programmer need not know the internal working of the hardware and need only the knowledge BIOS routines and their parameters. Three Layered Approach In the third case the programmer may invoke operating systems (DOS or whatever) routines in order to perform I/O operations.The operating system in turn will use BIOS routines or may program the hardware directly in order to perform the operation.

Methods of I/O In the three layered approach if we are following the first approach we need to program the hardware. The hardware can be programmed to perform I/O in three ways i.e.Programmed I/O Interrupt driven I/O Direct Memory AccessMethods of I/O programmed I/O:the CPU continuously checks the I/O device if the I/O operation can be performed or not.If the I/O operations can be performed the CPU performs the computations required to complete the I/O operation and then again starts waiting for the I/O device to be able to perform next I/O operation.Methods of I/O In this way the CPU remains tied up and is not doing anything else besides waiting for the I/O deviceMethods of I/O Interrupt driven I/O: the flaws of programmed driven I/O are rectifiedThe processor does not check the I/O device for the capability of performing I/O operationrather the I/O device informs the CPU it can perform I/O operationas a result the execution of CPU is interrupted and an Interrupt Service Routine (ISR) is invoked which performs the computations required for I/O operation.After the execution of ISR the CPU continues with whatever it was doing beforeMethods of I/O In this way the CPU does not remain tied up and can perform computations for other processes while the I/O devices are busy performing I/O and hence is more optimal. Methods of I/O Direct Memory Access (DMA):Direct Memory Access (DMA) means CPU grants I/O module authority to read from or write to memory without involvement. DMA module controls exchange of data between main memory and the I/O device.Because of DMA device can transfer data directly to and from memory, rather than using the CPU as an intermediary, and can thus relieve congestion on the bus.Methods of I/O Usually it takes two bus cycles to transfer data from some I/O port to memory or vice versa if this is done via some processor register.This transfer time can be reduced bypassing the CPU as ports and memory device are also interconnected by system bus.This is done with the support of DMA controller.The DMA (direct memory access) controller can controller the buses and hence the CPU can be bypassed data item can be transferred from memory to ports or vice versa in a single bus cycle.I/O controllers

No I/O device is directly connected to the CPU. To provide control signals to the I/O device a I/O controller is required.I/O controllersI/O controller is located between the CPU and the I/O device.For example the monitor is not directly collected to the CPU rather the monitor is connected to a VGA card and this VGA card is in turn connected to the CPU through busses.the keyboard is not directly connected to CPU rather its connected to a keyboard controller and the keyboard controller is connected to the CPUI/O controllers The function of this I/O controller is to provide I/O control signals Buffering Error Correction and Detection We shall discuss various such I/O controllers interfaced with CPU and also the techniques and rules by which they can be programmed to perform the required I/O operation. I/O controllers Some of such controllers are DMA controller Interrupt controller Programmable Peripheral Interface (PPI) Interval Timer Universal Asynchronous Receiver Transmitter Reading assignmentDMA controller Interrupt controller Programmable Peripheral Interface (PPI) Interval Timer Universal Asynchronous Receiver Transmitter Operating systems Systems programming is not just the study of programmable hardware devices.To develop effective system software one needs to the internals of the operating system as well.An operating system is a program that acts as an interface between the user and the computer hardware and controls the execution of all kinds of programs.Operating systems

Operating systems Operating systems make use of some data structures or tables for management of computer resources.Following are some of important functions of an operating System.File ManagementMemory Management Viruses and VaccinesProcessor Management Device ManagementetcOperating systems File Management:File management is an important function of the operating systems. DOS/Windows uses various data structures for this purpose.The various data structures are popularly known asFAT which can be of 12, 16 and 32 bit wide,Other data structures include BPB(BIOS parameter block), DPB( drive parameter block) and the FCBs(file control block) which collectively forms the directory structure.

Operating systems To understand the file structure the basic requirement is the understanding of the disk architecture, the disk formatting process and how this process divides the disk into sectors and clusters. Operating systems Memory management:Memory management is another important aspect of operating systems. Memory management refers to management of Primary Memory or Main Memory. Main memory is a large array of words or bytes where each word or byte has its own address. Operating systems Main memory provides a fast storage that can be access directly by the CPU. So for a program to be executed, it must in the main memory.Operating System does the following activities for memory management. Keeps tracks of primary memory i.e. what part of it are in use by whom, what part are not in use. In multiprogramming, OS decides which process will get memory when and how much.Operating systems Allocates the memory when the process requests it to do so. De-allocates the memory when the process no longer needs it or has been terminated.Operating systems Viruses and Vaccines :Once an understanding of the file system and the memory Management it is possible to understand the working of viruses.Virus is a simple program which can embed itself within the computer resources and propagate itself. Mostly viruses when activated would perform something hazardous. Operating systems Processor Management:In multiprogramming environment, OS decides which process gets the processor when and how much time.This function is called process scheduling.Operating System does the following activities for processor management. Operating systems Keeps tracks of processor and status of process. Program responsible for this task is known as traffic controller. Allocates the processor (CPU) to a processDe-allocates processor when processor is no longer required. Operating systems Device Management :OS manages device communication via their respective drivers. Operating System does the following activities for device management. Keeps tracks of all devices. Program responsible for this task is known as the I/O controller.Decides which process gets the device when and for how much time. Allocates the device in the efficient way. De-allocates devicesOperating systems Other Important Activities:Following are some of the important activities that Operating System doSecurity -- By means of password and similar other techniques, preventing unauthorized access to programs and data. Control over system performance -- Recording delays between request for a service and response from the system.

Operating systems Job accounting -- Keeping track of time and resources used by various jobs and users. Error detecting aids -- Production of dumps, traces, error messages and other debugging and error detecting aids.Coordination between other software and users -- Coordination and assignment of compilers, interpreters, assemblers and other software to the various users of the computer systems.Operating systems Types of Operating Systems:Operating systems are there from the very first computer generation.Operating systems keep evolving over the period of time. Following are few of the important types of operating system which are most commonly used. Operating systems Batch operating system:The users of batch operating system do not interact with the computer directly.Each user prepares his job on an off-line device like punch cards and submits it to the computer operator. To speed up processing, jobs with similar needs are batched together and run as a group.Operating systems Thus, the programmers left their programs with the operator. The operator then sorts programs into batches with similar requirements.The problems with Batch Systems are following. Lack of interaction between the user and job. CPU is often idle, because the speeds of the mechanical I/O devices are slower than CPU.Difficult to provide the desired priority. Operating systems Time-sharing operating systems :Time sharing is a technique which enables many people, located at various terminals, to use a particular computer system at the same time.Multiple jobs are executed by the CPU by switching between them, but the switches occur so frequently.Thus, the user can receive an immediate response. Operating systems For example, in a transaction processing, processor execute each user program in a short burst or quantum of computation. That is if n users are present, each user can get time quantum. When the user submits the command, the response time is in few seconds at most.Operating systems Operating system uses CPU scheduling and multiprogramming to provide each user with a small portion of a time.Computer systems that were designed primarily as batch systems have been modified to time-sharing systems. Operating systems Advantages of Timesharing operating systems are following Provide advantage of quick response. Avoids duplication of software. Reduces CPU idle time.Disadvantages of Timesharing operating systems are following. Problem of reliability. Question of security and integrity of user programs and data. Problem of data communication.Operating systems Distributed operating System:Distributed systems use multiple central processors to serve multiple real time application and multiple users.Data processing jobs are distributed among the processors accordingly to which one can perform each job most efficiently. The processors communicate with one another through various communication lines (such as high-speed buses or telephone lines).Operating systems These are referred as loosely coupled systems or distributed systems.Processors in a distributed system may vary in size and function. These processors are referred as sites, nodes, and computers and so on.Operating systems The advantages of distributed systems are following. With resource sharing facility user at one site may be able to use the resources available at another.Speedup the exchange of data with one another via electronic mail. If one site fails in a distributed system, the remaining sites can potentially continue operating. Better service to the customers. Reduction of the load on the host computer. Reduction of delays in data processing. Operating systems Network operating System :Network Operating System runs on a server and provides server the capability to manage data, users, groups, security, applications, and other networking functions.The primary purpose of the network operating system is to allow shared file and printer access among multiple computers in a network, typically a local area network (LAN), a private network or to other networks.Operating systems Examples of network operating systems are Microsoft Windows Server 2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD. The advantages of network operating systems are following.Centralized servers are highly stable. Security is server managed.Upgrades to new technologies and hardware can be easily integrated into the system.Remote access to servers is possible from different locations and types of systemsOperating systems The disadvantages of network operating systems are following.High cost of buying and running a server. Dependency on a central location for most operations. Regular maintenance and updates are required. Operating systems Real Time operating System:Real time system is defines as a data processing system in which the time interval required to process and respond to inputs is so small that it controls the environment. Real time processing is always on line whereas on line system need not be real time.The time taken by the system to respond to an input and display of required updated information is termed as response time.Operating systems So in this method response time is very less as compared to the online processing. Real-time systems are used when there are rigid time requirements on the operation of a processor or the flow of data and real-time systems can be used as a control device in a dedicated application. Real-time operating system has well-defined, fixed time constraints otherwise system will fail. Operating systems For example Scientific experiments, medical imaging systems, industrial control systems, weapon systems, robots, and home-appliance controllers, Air traffic control system etc.There are two types of real-time operating systems. Hard real-time systems Soft real-time systemsOperating systems Hard real-time systems :Hard real-time systems guarantee that critical tasks complete on time.In hard real-time systems secondary storage is limited or missing with data stored in ROM.In these systems virtual memory is almost never found. Operating systems Soft real-time systems:Soft real time systems are less restrictive. Critical real-time task gets priority over other tasks and retains the priority until it completes.Soft real-time systems have limited utility than hard real-time systems. For example, Multimedia, virtual reality, Advanced Scientific Projects like undersea exploration and planetary rovers etc.Operating systems Operating System Services:Program execution I/O operations File System manipulation Communication Error Detection Resource Allocation Protection