130 likes | 223 Vues
EE551 Real-Time Operating Systems. Processes, Threads and Tasks Course originally developed by Maj Ron Smith. Processes. The process is the most central concept in an operating system A process is an abstraction of a running program
E N D
EE551 Real-Time Operating Systems Processes, Threads and Tasks Course originally developed by Maj Ron Smith
Processes • The process is the most central concept in an operating system • A process is an abstraction of a running program • A number of processes (at least more than one) executing at the same time is referred to as: multitasking, multiprocessing multithreading, multiprogramming • Are these programs truly running in parallel? Dr Alain Beaulieu
The Process Model • The process model is simply the idea that all runnable software on the computer (including the OS) is organized into a number of sequential processes Dr Alain Beaulieu
Processes on a single processor Conceptual Program Text Flow Process Execution in Time Dr Alain Beaulieu
Virtual process parallelism • Requires that we keep the state of a process to be able to re-establish it after interrupts • From hardware devices • Position limit detectors, Resolvers, • Clocks (tics) • Software Interrupts (system calls) • Context Switch – What is a context? Dr Alain Beaulieu
Process States So the tasks in the ready and blocked state have some info stored but what? Dr Alain Beaulieu
Implementation of Processes Not really for RTOS in Embedded systems Typical Fields in a Process Table Entry (depends on OS) Dr Alain Beaulieu
The Thread Model • Traditional operating systems have a number of processes each with an address space and a single thread of control • The process model discussed previously was based on two independent concepts: • Resource grouping • Address space (program text & data), open files, child processes, pending alarms, signal handlers, etc. • Execution (Thread of Execution or Thread) • The part of the program text that is running Dr Alain Beaulieu
The Thread Model • Processes vs. Threads: Dr Alain Beaulieu
Threads in User Space • Each process needs a thread table • Similar to a process table, but tracks only: • Program Counter • Stack Pointer • Registers • State • Table managed by the run-time system Dr Alain Beaulieu
Threads in Kernel Space • Put the concept of the thread in the kernel • There is no need of a run-time system • The kernel has a thread table • Threads make calls to the kernel for thread creation/termination • Kernel holds each thread’s registers, state, etc... Dr Alain Beaulieu
Tasks? • So we understand that a process has everything to do with Resources allocated to a program • Virtual (including time such as alarms) • Physical • A thread has everything to do with the Execution of a program • So what is a task in the realm of µC/OS? Dr Alain Beaulieu
Multitasking • A task in µC/OS lives in a process that includes the operating system as it is compiled and linked with the solution code • A single task in µC/OS would therefore look like a process it has resources and it is a program in execution • A task also looks like a thread because it has its own stack and shares the resources with other tasks. Dr Alain Beaulieu