Micro
Micro
Micro
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Function
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Function Function is an entity used in any program, function, task or thread for performing specific set of actions when called and on finishing the action the control returns to the function calling entity (a calling function or task or process or thread).
2008 Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 3
Function Each function has an ID (name) has program counter and has its stack, which saves when it calls another function and the stack restores on return to the caller. Functions can be nested. One function call another, that can call another, and so on and later the return is in reverse order
2008 Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 4
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Task
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Task Task defined as an executing computational unit that processes on a CPU and state of which is under the control of kernel of an operating system.
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
Uses
Function for running specific set of codes for performing a specific set of actions as per the arguments passed to it ISR for running on an event specific set of codes for performing a specific set of actions for servicing the interrupt call Task for running codes on context switching to it by OS and the codes can be in endless loop for the event (s)
2008 Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 10
Calling Source
Function call from another function or process or thread or task ISR interrupt-call for running an ISR can be from hardware or software at any instance Task A call to run the task is from the system (RTOS). RTOS can let another higher priority task execute after blocking the present one. It is the RTOS (kernel) only that controls the task scheduling
2008 Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 11
Context Saving
Function run by change in program counter instantaneous value. There is a stack. On the top of which the program counter value (for the code left without running) and other values (called functions context) save All function have a common stack in order to support the nesting
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
12
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
13
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
14
Context Saving
ISR Each ISR is an event-driven function code. The code run by change in program counter instantaneous value. ISR has a stack for the program counter instantaneous value and other values that must save. All ISRs can have common stack in case the OS supports nesting
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
15
Context Saving
Task Each task has a distinct task stack at distinct memory block for the context (program counter instantaneous value and other CPU register values in task control block) that must save Each task has a distinct process structure (TCB) for it at distinct memory block
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
16
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
17
Response and Synchronization Function nesting of one another, a hardware mechanism for sequential nested mode synchronization between the functions directly without control of scheduler or OS
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
18
Response and Synchronization ISR a hardware mechanism for responding to an interrupt for the interrupt source calls, according to the given OS kernel feature a synchronizing mechanism for the ISRs, and that can be nesting support by the OS
2008 Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 19
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
20
Structure Function can be the subunit of a process or thread or task or ISR or subunit of another function
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
21
Structure
Task is independent and can be considered as a function, which is called to run by the OS scheduler using a context switching and task scheduling mechanism of the OS. The system, during running of a task, can let another higher priority task run. The kernel manages the tasks scheduling
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
23
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
24
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
25
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
26
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
27
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
28
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
29
Summary
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
30
We learnt
Function is used in any routine for performing specific set of actions as per the arguments passed to it and which runs when called by a process or task or thread or from another function. Functions run by nesting and thus have a common stack. Function runs after the previous context saving and after retrieving the context from a common stack
2008 Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 31
We learnt
An ISR is a function, which executes on interrupts (events). Executes on an event and pending ISRs run as per priority based scheduling. Can post the events or signals or messages ISRs generally run by nesting. Runs after the context saving and after retrieving the context Generally OS provides for a common stack for ISRs. Runs as per the hardware based interrupt-handling mechanism
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 32
2008
We learnt
A task is a function, which executes on scheduling and has independent stack and context, can wait as well as post the events or signals or messages. Runs after saving of the previous context at the task TCB and the context switching to new context at the new task TCB. The tasks run as per the task scheduling and IPC management mechanism of the OS
2008 Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc. 33
2008
Chapter-7 L5: "Embedded Systems - Architecture, Programming and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
34