• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Intro To Vxworks RTOS
 

Intro To Vxworks RTOS

on

  • 3,850 views

 

Statistics

Views

Total Views
3,850
Views on SlideShare
3,834
Embed Views
16

Actions

Likes
1
Downloads
128
Comments
0

2 Embeds 16

http://www.linkedin.com 14
https://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Intro To Vxworks RTOS Intro To Vxworks RTOS Presentation Transcript

    • Introduction to VxWorks RTOS Eli Carmi July 2007
    • Introduction to VxWorks RTOS∗ RTOS∗ Tasks∗ Synchronization∗ Asynchronous∗ Information 2
    • RTOS - Real Time OS∗ RTOS ∗ Real Time ∗ Multi Tasking ∗ Priority Scheduling ∗ Round-Robin Scheduling 3
    • Real Time∗ Control External Events ∗ Synchronous Event ∗ Asynchronous Event ∗ Independents Event∗ Speed ∗ Fast response ∗ Low overheads∗ Deterministic ∗ A late answer is a wrong answer 4
    • Multi Tasking∗ Sequence programming ∗ One task controlling all events in a Loop FOREVER { if (Event1) do Event1 action if (Event2) do Event2 action … } 5
    • Multi Tasking cont.∗Multitasking Programming ∗ Task is “Waiting” on Event ∗ Task becomes “Ready” upon Event Task1 Task2 Task3 FOREVER FOREVER FOREVER { { { wait on Event1 wait on Event2 wait on Event3 do Event1 action do Event2 action do Event3 action } } } 6
    • Priority Scheduling∗ Task in the system may have different Priority∗ Preemptive Scheduling on Task Priority∗ The Highest Priority Task ready to run is allocated the CPU∗ Equal Priority tasks won’t preempt each other∗ Scheduling can occur by Synchronous or Asynchronous Events∗ No delay on Context Switch to the next Tick 7
    • Round-Robin Scheduling∗ Slicing ∗ Context Switch in each (predefined) time slice period∗ Round-Robin ∗ All tasks in the same priority share the CPU 8
    • Tasks∗ Tasks ∗ Task States ∗ Task Create (t-name, t-id) ∗ TCB, Stack, errno… ∗ Context Switch 9
    • Task States∗ Delay∗ Pended Event Task Task Task Pended Pended Pended∗ Ready Task Task∗ Execute Event Pended Pended Task∗ Suspend Timer Task Task Delay + Pended Delay Delay Ready Task Task Task Task execute ready ready ready 10
    • Task Create∗ taskId = taskSpawn(name, Priority, Option, Stack, Entry, Arg1,… arg10 ) ∗ task Id ∗ Task name ∗ Priority ∗ Option ∗ Stack ∗ Entry ∗ Arg1,…arg10 11
    • TCB∗ TCB – Task Control Block ∗ Entry pointer ∗ Registers ∗ Status ∗ Errno ∗ …∗ Task Stack ∗ May be filled with 0xee 12
    • Context SwitchNew TCB CPU Old TCB 13
    • Synchronization∗ Synchronization ∗ Need for Synchronization ∗ Binary Semaphores ∗ Mutex Semaphores ∗ Message Queue 14
    • Need for Synchronization∗ Reentrancy & Shared Resource … void func() { …. if (gResource.free) { gResource.free = FALSE; gResource.xxx = … } ….∗ Jobs Synchronization } …. Action1 …. Action2 15
    • Binary Semaphores∗ Mostly for Synchronization∗ Creates Semaphore for Event∗ Waits for Event ∗ Task call the semaphore take() action ∗ Task is blocked until Event Semaphore is given∗ Upon Event becomes available ∗ Task or ISR give() semaphore 16
    • Binary Semaphores (cont)∗ SEM_ID semBCreate(option, InitState) ∗ SEM_ID ∗ Option ∗ InitState∗ Status semTake(semid, timeout)∗ Status semGive(semid, timeout) ∗ Status ∗ semid ∗ Timeout∗ Note: Counting Semaphores also available 17
    • Binary Semaphores (cont)∗ Taking a Binary Semaphore Task pends Semaphore No Timeout Task unpends until sem Available? semTake() is given return ERROR or timeout Yes Semaphore give Task continue Task unpends semTake() semTake() return OK return OK∗ Giving a Binary Semaphore Task No Semaphore Pended? Made available Yes Task at front of queue made ready, 18 Semaphore remain unavailable
    • Mutex Semaphores∗ Mostly for Shared Resource∗ Works like Semaphores, but with Ownership ∗ Task which takes the mutex “owns” it ∗ This task is the only one that can give the mutex ∗ Mutex can be takes repeatedly ∗ ISR can not use Mutex∗ SEM_ID semMCreate(option) ∗ Option (SEM_INVERSION_SAFE,…) ∗ Priority Inheritance ∗ Initial State is available 19
    • Mutex Semaphores (Cont)∗Priority Inversion Event semTak High Pend execute Pend Priority Event Medium Pend Pend Ready execute Priority semTak Low execute Ready Priority∗Priority Inheritance 20
    • Message Queue∗ Msg_Q_ID msgQCreate (maxMsg, MaxMsgLen, Option) ∗ MSG_Q_ID ∗ maxMsg ∗ MaxMsgLen ∗ Option 21
    • Message Queue (cont)∗ Status msgQSend(msgQId, buffer, nBytes, timeout, priority) ∗ Status ∗ msgQId ∗ buffer ∗ nBytes ∗ Timeout (WAIT_FOREVER, NO_WAIT, …) ∗ Priority (MSG_PRI_URGENT, MSG_PRI_NORMAL) 22
    • Message Queue (cont)∗ Int msgQReceive(msgQId, buffer, MaxNBytes, timeout) ∗ Int –number of bytes reads or ERROR ∗ msgQId ∗ buffer ∗ nBytes ∗ Timeout (WAIT_FOREVER, NO_WAIT, …)∗ Note: Pipes are also available ∗ Built on top of message queue 23
    • Asynchronous∗ Asynchronous ∗ Interrupts & Exceptions ∗ ISR ∗ Timers 24
    • Interrupts & Exceptions∗ Interrupts ∗ Interrupts allow devices to notify the CPU on events ∗ Interrupt Levels ∗ Single Interrupt Stack allocate at startup∗ Exceptions ∗ Unplanned event generated by the CPU (divide by 0) ∗ Exceptions will generate an “internal” interrupt ∗ VxWorks installs exceptions handlers∗ intLock / intUnlock 25
    • ISR∗ ISR – Interrupt Service Routine∗ NOT a Task ∗ No TCB ∗ Can NOT be blocked (can’t use semTake, malloc and IO routines like printf)∗ Keep ISR short ∗ Delay lower and equal Interrupts ∗ Delay all Tasks∗ Off-load work from ISR 26
    • Timers∗ taskDelay() ∗ May “Drift”∗ System Clock ∗ tickGet() ∗ sysClkRateGet()∗ Watchdog ∗ WDOG_ID wdCreate() ∗ STATUS wdStart(wdid, delay, pRoutine, parameter) ∗ pRoutine is ISR∗ Note: Auxiliary Clock is also available 27
    • Thank Youeli.carmi@gmail.com