Showing posts with label rtos. Show all posts
Showing posts with label rtos. Show all posts

Saturday, May 19, 2012

Thread Safe?


"Every function that uses files in some way. This  includes printf, scanf, getchar, and putchar (unsafe). The functions sprintf and  sscanf are not included (safe)." They (former) need mutex in a certain way to serialize these operations. 

  • Thread(or task) is an entity in multi-tasking and they can share memory (global variable) with mutex mechanism. / threads are under the same application.
  • An application (process) can launch multiple threads.
  • Process is a standalone self-contained application and it "cannot" share the global variables. (They run on the different contexts -  属性 ) They can only communicate thru IPC channel.
  • Multiple processes can run on a CPU.



Thursday, May 17, 2012

RTOS

Real time OS implements mechanism to support low latency to requests (mainly from HW) Used in critical system.
  • Multi-tasking
  • Preemtion (time sharing & context switching)
  • Interrupt handler == ISR (interrupt service routine) <--> Polling
  • Mutual exclusion (semaphore)
Dead lock/ Example: circular waiting
A <- B <- C and then C <- A


ISR
(From Wiki) A hardware interrupt causes the processor to save its state of execution and begin execution of an interrupt handler.
Software interrupts are usually implemented as instructions in the instruction set, which cause a context switch to an interrupt handler similar to a hardware interrupt.