Real time Operating system Unit 5 chp 1 OPERATING SYSTEM? • Manages operates and communicate with hardware and software • Provide resources to user • Manages the hardware • Interface between hardware and user PARTS OF OS USER INTERFACE KERNEL DEVICE DRIVERS SYSTEM UTILITIES • DEVICE DRIVERS: a group of file that enable one hardware device to communicate with OS. • KERNEL: Central component of OS. interface between hardware and software. • User interface: by means of which the user interacts with the os. • System utilities: system software that perform maintenance type task. Need of operating system • Identify input from input device and send output to the output devices • Keep track of the file and directories • Control peripheral device printer,scanner. • Heart of computer is CPU. Operating system basics • Bridge between user applications and underlying system resources. • OS makes the system convenient to use. • Organizes and manages the system resources efficiently and correctly. Function of OS • Process management i. Provide accesss to shared resources. ii. Control execution of user app iii. Create execute and delete the user and system process. iv. Schedule a process. v. Synchronization, deadlock handling and inter process communication. • Memory management i. Allocate memory ii. Free the memory after completion of execution. iii. Reallocates memory iv. Keep track of usage. • File management i. Create and delete files. ii. Provide access to file. iii. Maintain backup. iv. File security. • Device management i. Open ,close and write device drivers. ii. Communicate, monitor and control the drivers. • Protection and Security i. Resources are protected by OS ii. User authentication ,file attributes such as read, write, encryption,back up are used for protection • User interface and Command interpreter i. Os work as an interface between the user and the hardware. ii. This interface is made of GUI or commands. • Booting the computer i. Starting and restarting. ii. Cold booting- PC is completely switched off and turned on. iii. Warm booting- restarting. • Perform basic computer tasks i. Peripheral devices are managed by OS • Kernel -core of OS. -responsible for managing the system resources. -communication amoung the hardware and other programs. -have different service to handle the following tasks. i) Process management -manages the process. -setting up memeory space,loading the process code in memory space,allocating system resources and manageing the process control. ii) Primary memory management -keeping track of which part of the memory area is currently used by which process. -allocating and de allocating the memory space. iii) File system management -creation deletion and alteration of directories. -saving files in secondary memory. -provide flexible name convention for the files. iv) I/O system management -kernels maintain the list of all the I/O devices of the system. -responsible for routing the request(I/O) coming from different user. -loading and unloading device drivers. -exchange information and control signals to and from the device. v) Secondary storage management - Deals with managing secondary storage memory devices. - Disk storage allocation. - Free disk space management. • Kernel space and user space -the memory space at which the kernel code is located is called kernel space. -user application are located onto the specific area in primary memory is called user space. -the act of loading code into and out of the memory is called swapping. Monolithic system • All the component of the OS are all integrated under a single unit as kernel mode. • No separate user and kernel mode. • Adding or removing any feature is quite difficult. • If any program crashes then the entire system crashes. • No context switching hence faster than the other type. • Hard to extend. • Eg : ms DOS, window 95,98. Monolithic kernel vs microkernel • Monolithic: entire OS code is executed in kernel mode • difficult to change OS code • Drawbacks: reliability and maintainability. • Microkernel:2 mode user and kernel. • In user mode all the components are present ie memory module user module process module. • In kernel mode contains code to pass system calls, context switching. Objectives of OS • Convenience- system can be conveniently used. • Efficency- resources can be used in efficient manner. • Ability to evolve- allow efficient development, testing and introduction of new function without interfering with services. System calls • Interface between OS and user program. • There are two modes in which a program can executed ie user mode and kernel mode. • User mode: have no direct access to resources. • Kernel mode(privileged mode):have direct access to resources. • If a program happens to execute in a kernel mode and if it crashes then the entire system will come to a halt. • If it executes in a user mode then it doesn’t have any problem. Processes i. A program or application under execution. ii. Computer program in a text file executes main memory process iii. To complete a process execution one process(parent) create a new process (child). iv. Processes identified by process identifier(pid) an integer number. v. Process require resources for completing of task. vi. Subprocess also require resource so it can directly ask from OS. vii. After creation of new process 2 possibility: - the child carries on executing in parallel with its children - the parents wait until the child terminates. Process state and process state transition diagram • During execution a process changes it state. • State show current activity of a process. • Each process remain in one of the 5 states. • Queue associated with each state of the process. • Process resides on that queue. • New state: new process being created. • Ready state: A process is ready to run but it is waiting for CPU being assigned to it. • Executing state: A process is said to be in running state if currently CPU is allocated to it and it is execution. • Waiting state: A process cant continue it’s execution because it is waiting for the event to happen such as I/O completion. • Terminated state: the process has completed it’s execution. Critical Regions • The area in which the process access the shared resource then it is in critical region. • Many solutions are there for critical sections. • But all the solution must fulfil these criteria: 1. Mutual exclusion : critical region must be accessed by one process at a time. 2. Progress: only those process who wants to access the shared resources will enter in the critical section. 3. Bounded wait: there must a bounded wait for which a process must wait to enter into critical section. Scheduling • removal of the running process from the CPU and the selection of another process. • OS selects the process from queue. • This selection is carried out by the program scheduler called scheduler. • 3 type: Long term Short term Medium term • Long term scheduler -comes into picture when new process are created. -its job is to choose the process from the queue and place them into main memory for execution. -from new to ready queue. • Short term scheduling -process in the ready queue wait for the CPU. -short term schedular chooses the process from the ready queue and assign CPU to it. -policies FCFS, SJF, priority based, round robin. -faster than Long term -redy state to running state. • Medium term schedular -in multiprogramming,helps to swap out the process and also swap in the process. Scheduling algorithm • FIFO(first in first out) -non preemptive scheduling. -allocates CPU in order of arrival. -treats ready queue as FIFO. -does not give up CPU unless terminated or need I/O. -longer jobs assign to CPU the shorter jobs has to wait. -fewer throughput. • Shortest job first(SJF) -it is non preemptive. -reordering so as to improves average response time. -ready queue is maintained in increasing job lengths. • Round robin -a small unit is called quantum. -CPU is allocated to each process for this time quantum. -ready queue is treated as FIFO. -time quantum expires,context switch occur and CPU switches to other process. -quantum can be very large or very small. -large:will behave like FIFO/FCFS. -small: increase context switch leading to performance degradation. Deadlock • In a multiprogramming, a number of process compete for limited number of ressources and if a resource is not available at that instance then process enters into waiting state. • If a process unable to change its waiting stateindefinitely because the resources requested byit is held by another waiting process then system is said to be in deadlock. Preemptable and non preemptable resources • Preemptable -this resources can be taken back from the process to which it was allocated with no ill effect eg memory • Non preemptable -this resources cannot be taken back from then process to which it was allocated without potentially causing failure eg printer • Following are the sequence of step when a process may utilize a resource 1)Request 2)use 3)Release Types of OS Type of OS General purpose Real time Os General purpose OS(GPOS) • Non deterministic • Usually deployed in the computing system where deterministic behavior is not an important criterion. • Eg personal computer ,desktop system. Real time OS(RTOS) • Implements policies and rules time critical allocation of a system resources. • Decides which application runs in which order and how much time needs to be allocated for each application. • Hard and soft are the two types of RTOS. • Windows CE,QNX eg RTOS Characteristics. • Sufficient time. -a critical real time system require suitable time for processing an external stimulus. -this is known as response time . -real time system is considered by correctness such that logical outputs correctness and timeliness. • Sample Applicationi - It is important to consider one of its application to understand these characteristics of RTOS. - Eg robotics, cars, complex multimedia animation system. • Time constraints. - Time contraints ae what that distinguish real time OS. - If time constraints are not met system failure occur in a hard real time. - Time constraints have to be met in majority of cases in a firm real time. - A degradation of performance with any failure to meet time constraints is ocuur in soft rel time. Selection of OS(criteria) • Is your application real time? • Is memory size limited? • Is CPU power limited? • Is device power consumption an issue? Design and development Unit 5 chp 2 Embedded System Development lifecycle. (EDLC) • Analysis,design , implementation based problem solving method for embedded system development. • Explains various phases of embedded development. • Economics and reality of design requirement can force decision to be made before designer can consider the best design trade off. • Defects can force you bac to the beginning . • To overcome performance issue rewrite algorithm ,design custom hardware, speed up processor, new processor. • Because of all these problem EDLC Is important in embedded product development. Concept EDLC in embedded product development lifecycle. • Problem solving approach. • Analysis is where we desire product which is to be develop. • Design, construction or building of product is the main concern. • Implementation , development of a product is done here. • EDLC understands scope and complexity of work involved in and embedded development. Analysis Design implementation • Phases of design is shown in figure Need of EDLC • Essential in understanding scope and complexity of work involved in and embedded development. • Defines interaction and activities amoung various gropu of product development sector. - Project management. - System design and development. - System testing. Objectives of EDLC - Product has to meet the user requirement. Ensuring that high quality of products are deleivered to the user. Risk minimization and defect prevention in product development Maximize productivity. Product development lifecycle • Concept phase-phase involve brainstorming of innovative ideas driven by technology trend and customer input • Requirement gathering phase- determines what kind of hardware and software is required to satisy the customer. • Design phase- the product owner and design team will identify the relationship between input and output. concept requirement design development integration Var and val development retire • Development and implementation phase-based on the specification of all the different hardware add on components are chosen and hardware implementation will start. • Integration phase- testing of the entire system. • Verification and validation development-verification includes checking documents,design, code, and program.it does not involve executing the code. Validation includes dynamic mechanism of testing and validating the actual product. It involves executing the code. • Retire- disposal of product is essential due to rapid technology advancement, increased user need. EDLC phases Different phases of EDLC • Need - Need may come from an individual or from public or from company. - Need should be said to initiate the development life cycle. - Need can be visualized in any one of the following needs i) Custom product development. ii) Product re engineering iii) Product maintenenace. • Conceptualisation - Defines scope of concept, cost benefit analysis, feasibility study, and prepare project management and risk management plan. - Feasibility study- examine the need and suggest possible solution. - Cost benefit analysis- revealing and assessing the total development cost and profit expected. • Analysis - Operational requirement, operational and non operational quality attributes, user manuals. - Define test plans and procedure eg unit testing,integratipn testing, system testing, user acceptance testing. • Design - Design phase identifies application environment and creates an overall architecture - Starts with preliminary design.establishes the top level architecture for the product. And it is called black box. Final result of this is called preliminary design document. - Once PDD is accepted by the end user the next task is to create the detailed design. • Development and testing - This phase transform the design into a realizable product. - Testing includes unit, integration,system and user acceptance. • Deployment - Process of launching the first fully functional model of the product in the market. - Following task are performed - Execution of training plan-proper training should be given to the end user to be aware of the new product. - Product installation. - Product post implementation review- after the product launches a post implementation review is done to test the success of the product. • Support -bugs in the product is observed and reported. - Support phase certifies that the product meets the user needs and it continues in the production environment. - Following task involves - Setting up of a dedicated support wings- involves providing 24x7 support of the product after launch - Identify bugs and area of improvement • Upgrades -deals with the development of upgrades of the product which is already present in the market. - Product upgrade result as an output of major bug fixes - The system is subject to design modification to fix the major bugs report. • Retirement - disposal of product is essential due to rapid technology advancement, increased user need. Trends in embedded industry • Processor trends • Trends in processor architecture • Operating system trends. • Trends in development language. Processor trends First generation of processor/controller • Few gates per chips • It needs brownout circuit and timer • Slow in terms of number of instruction executed. • It executes at a frequency of a few MHz only. • Designed using the processors available at that time. Today’s generation processor/controller • Ten thousand gates per chip. • It have all the components on the same chips. • Advanced architecture support features like instruction pipelining for improving the execution speed. • Capable of achieving execution of range of GHz. • It is possible to create custom processor according to the product requirement. Trends in processor architecture • System on chip-all functional requirement to build an ES embedded into one chip. • Multicore processor-multiple core on the same processor. • Reconfigurable processor-depending on the requirement this processor can change their functionality according to requirement. Operating system trends • OS customized for specific device requirement. Development language trends. • Embedded firmware -it is the application that is responsible for execution of embedded system. -it is the software that performs low level hardware interaction, memeory management . • Embedded software. -the software that runs on the host computer and is responsible for interfacing with embedded system. -it is the user application that that executes on the top of the embedded system -languages like Microsoft c$,java ,ASP.NET,etc available for embedded system development. 1. Java. -not so popular for ES due to its ececution behavior. -java programs are compiled by a compiler into byte code. -this byte code are converted by JVM into processor specific object code. -during runtime, this interpretation makes java application slower than other. -this disadvantage is overcome by providing in built hardware support for java byte code. 2. .NET CF - Stands for compact framework. - Replacement of the original. - NET framework to be used on ES. - CF version is customized to contain all the necessary components for application development. - Original framework was very large and not a good choice for embedded development. - The .NET framework is the collection of precompiled libraries. - Common Language Runtime(CLR) is the run time environment . - Application written in .NET are compiled to a platform neutral language called Common Intermediate Language(CIL). - For execution, CIL is converted to target specific machine instruction by CLR. Embedded system development environment -IDE • An Integrated Development Environment (IDE) is software that assists programmers in developing software • IDEs normally consist of a source code editor, a compiler, a linker/locater and usually a debugger. • an IDE is dedicated to one specific programming language or one (family of) specific processor or hardware. • Some commonly used IDEs for embedded systems are the GNU compiler collection (gcc), Eclipse, Delphi. • Editor -A source code editor is a text editor program designed specifically for editing source code to control embedded systems. • Compiler-A compiler is a computer program that translates the source code into computer language (object code). • Linker - A linker or link editor is a program that takes one or more objects generated by compilers and assembles them into a single executable program or a library that can later be linked to in itself. • Debugger - A debugger is a computer program that is used to test and debug other programs. • Simulators-Simulators try to model the behavior of the complete microcontroller in software. • Emulator-An emulator is a piece of hardware that ideally behaves exactly like the real microcontroller chip with all its integrated functionality. Types of files generated on cross compilation • List file(.lst) -contains information about cross compilater details,formatted source text, assembly code generated from the source file, errors and warning detected during the cross compilation.file contains following section i. Page header-shows compiler version name, source file name,date, page no. ii. Command line –it signifies the entire command line that was used for invoking the compiler. iii. Source code- contains source along with line number. iv. Assembly code- it has the assembly code generated by compiler for the given C code. v. Symbol listing- it has symbolic information abput the various symbos present in the cross compiled source files. vi. Module information- size of the memory defined by source file. vii. Error and warnings • preprocessor output file -it contains preprocessor output for preprocessor instruction. (The preprocessors are the directives, which give instructions to the compiler to preprocess the information before actual compilation starts.) • Object file (.OBJ) -cross compiling each source module converts the embedded C assembly instruction and other directive present in the module to the object(.OBJ) file. • Map file(.MAP) -map file contains about link/locate process i. Page header- linker version number,date,time pg no. ii. Command line- the entire command line that was invoking the linker. iii. Cpu details iv. Input modules-names of all the object files,library files,that are included in linking process. v. Memory map-list starting address, length,. vi. Intermodule cross reference-contains the section name,memory type and module name in which it is defined and all the modules name where it is accessed. vii. Program size-contains the size of various memory area viii. Errors and warning • Hex file(.hex) -binary executable file created by the source code. -file created by the linker is converted to understandable binary code. -The tool used for converting and object file into hex file is known as object to hex convertor. Disassembler and Decompiler. • It is reverse engineering tool. • It is used in embedded system to find out secret behing the working of proprietary oroduct. • A Disassembler is the utility program which converts machine code into target process. • A process of converting machine code to assembly language is called disassembling. • A Decompiler translates machine code to high level language instruction.reverse operation of compiler Simulators • Simulators try to model the behavior of the complete microcontroller in software. • No matter how fast your PC, there is no simulator on the market that can actually simulate a microcontroller's behavior in real-time. • Characteristic - Purely software based. - No need of the hardware(target system) - Support only basic operation. - Cannot support real time behavior. Advantages of simulation • Simple and straight forward - simuators are software utilitis with assumption about underlying hardware. • No hardware • Simulation option – options like I/O peripherals • Simulation of abnormal condition. - Code can be tested for any desired value. - Study code behavior in abnormal condition without testing it on the hardware. Disadvantage • Lack of real time behavior • Lack of real timeliness- the I/O condition in hardware is unpredictable. Debugging • Process of diagnosing firmware execution,monitoring the target processor register and memory while the firmware is running • Classified into hardware and firmware debugging • Hardware debugging-deals with various parts of hardware(multimeter) • Firmware debugging-deals with inspecting code, its execution flow(simulators and emulators) Emulator • Simulators try to model the behavior of the complete microcontroller in software. • An emulator is a piece of hardware that ideally behaves exactly like the real microcontroller chip with all its integrated functionality.