METE4400U_Lec03_OperatingSystems.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Transcript

Intro. to Real-Time Embedded Systems Lecture 3: Operating Systems Dr. Mitchell Rushton, Fall 2024 Operating Systems An Operating System (OS) is a collection of software that sits between the system hardware and application software An OS manages several important funct...

Intro. to Real-Time Embedded Systems Lecture 3: Operating Systems Dr. Mitchell Rushton, Fall 2024 Operating Systems An Operating System (OS) is a collection of software that sits between the system hardware and application software An OS manages several important functions, including: Process management Memory management Management of IO and other resources File system management Interrupt management Multitasking Operating Systems Most Operating systems in use today belong to one of two families: Windows, and Unix The Unix family includes Linux, Mac OS X, Android, FreeBSD, Solaris, and many other variants Operating Systems The part of an OS that contains the core system functions is called the ‘Kernal’ Additionally, an OS includes a set of Application Programming Interfaces (APIs) that allow user applications to request Kernal services through system calls Application API Kernel HW Program User Mode and System Mode The kernel is considered trusted code and is given full control over the CPU and all its functions (system or kernel mode) User processes and other parts of the OS are considered untrusted and can only perform a limited number of operations (user mode) The mode bit on the CPU determines which mode the CPU is in and can only be changed by the kernel System calls allow user processes to perform kernel mode functions through use of a trap and trap handler Process management A program is a static set of instructions A process is an active instance of a program that is being executed One of the major functions of the OS kernal is to create, terminate, and manage the various system and user-level processes that may be running at any given time Process Creation and Termination A process needs resources, such as CPU time, memory, I/O devices, and files, to accomplish its task. When creating a process, the OS kernel 1. Creates a new process object 2. Assigns the process a unique numerical process identifier (PID) 3. Assigns the process its own memory space and other resources, 4. Establishes a priority for the process in multi-tasking systems, 5. Loads program binary code into memory, and 6. Initiates execution When terminating a process, the OS kernel 1. Deletes the process object 2. Frees up and memory or resources held by the process Anatomy of a Process A process can have one or multiple threads A thread represents a single independent execution path Each thread has its own and stack and register backup Process level resources (such as memory space, and IO) are shared and accessible by all threads for a given process (a) Single-threaded process (b) Multi-threaded process A process cannot usually directly access addresses outside its assigned memory space Interrupt management An interrupt is a signal from a device attached to a computer or from a running process within the computer indicating an event that needs immediate attention. Processor responds by 1. suspending its current activities, 2. saving the system’s current state (backup system registers), and 3. executing a special function called an interrupt service routine (ISR), also called an interrupt handler, to respond to the event. After the ISR finishes, the previously saved system state is restored and execution continues from where it left of prior to the occurrence of the interrupt. Modern operating systems are interrupt driven: virtually all OS activities are initiated by the arrival of interrupts. Multitasking One of the main benefits of an OS is that it allows for multitasking while managing how common Task A OS Task B Interrupt or system call hardware resources are shared Executing The part of the OS that manages how CPU access Idle Save state into TCBa is shared is called the scheduler Restore state from TCBb Each task has a context, the data indicating its Executing execution state, stored in the task control block Idle (TCB), a data structure which contains all the Save state into TCBb information that is pertinent to the execution of the task. Restore state from TCBa Idle Executing The act of switching execution from one thread (or task) to another is called a context switch Real-Time Operating Systems Provide the benefits of regular operating systems Multitasking, resource sharing, etc. Make use of a special scheduler to enforce time constraints on processes and ensure deadlines are met. Examples Include: VxWorks, QNX, FreeRTOS, Windows Embedded Compact FreeRTOS Distributed freely under the MIT open-source license Includes a kernel and a growing set of IoT libraries FreeRTOS is a market-leading real-time operating system (RTOS) for microcontrollers Recommended for your project, if the use of an RTOS makes sense

Tags

operating systems embedded systems computer science
Use Quizgecko on...
Browser
Browser