Wednesday, January 30, 2013

TI C6000 SYS/BIOS (2)


  • Pulling is kind of like keep asking "ready? ready? ready?"
  • Interrupt is like domino, trigger one thing, then another, the goal is to tell CPU
  • C64+ interrupt:
  • Interrupt source: EDMA, timer, hardware pin, total 128 bytes, includes 124 unique and 4 combined
  • Interrupt selector: 128 (124+4) INT source go through mask to trigger 12 (16-4) INT, where the 4 is (0-reset, 1-NMI, 2,3- Emu0,1) 
  • Set flag in interrupt Flag Register (IFR)
  • check Individual Enable Interrupt (IER)
  • check Global Interrupt Enable (GIE)
  • Auto hardware sequence, IFR=0, PC->stack, Branch to ISR
  • IRS: context save, process, context restore, return Interrupt
  • 4 steps programming: interrupt selector, IER(enable it if you want to 'listen to'), GIE (enable it),  context save/restore.
  • HWI: fast response to INTs, minimum context switching, high priority to CPU, limited number of HWI. HWI prioritys set by hardware with fixed number
  • SWI: latency in response time, context switch, selectable priority levels, scheduler manages execution
  • SYS/BIOS provides for HWI and SWI management, allows HWI to post a SWI to the ready queue
  • SWI priority from 1-32, low to high. If a higher priority thread becomes ready, the running thread is preempted. If same priority, then FIFO
  • swi_post(mySwi): unconditionally post a software interrup
  • In SYS/BIOS, swi needs 280 cycles, task need 320 cycles.
  • Task has up to 32 priority levels, any number possible. All tasks are preempted by all SWI and HWI
  • All SWI are preempted by all HWI
  • Preemption among HWI is determined by user
  • In absence of HWI, SWI, and Task, Idle functions run in loop
  • Task codes: prolog, while(1), semaphone_pend(), process, Epilog.
  • Set up hardware timer need to define: tick rate (uS), clock module programs timer and ISR
  • Semaphore_pend() only waits on one flag - a semaphone, what if you want to unblock based on multiple events? Use Events. It can OR or AND event IDs with bit masks
  • Queue is a BIOS object that can contain anything you like, it is NOT copy based, use queue_put(), queue_get(). No signalling built in (cannot black)
  • Sync Queue using "talker and Listerner" mode. Talker: Queue_put(&myQ, msg); semaphone_post(&sem). Listerner: semaphore_pend(&sem, -1), msg=Queue_get(&myQ);
  • Mailbox is a fixed size BIOS object. Use Mailbox_post(...), Mailbox_pend(...). It is FIFO, contains built-in semaphore for signalling, it is copy-based so that you want to use a pointer, or small size data
  • MUTUX can cause priority inversion and deadlock
  • Two basic data sharing models are "producer-consumer" (queue, mailbox, semephore/event), "concurrent access" (mutex, same priority, scheduler management)
  • Threads at the same priority cannot pre-empt each other, it is a good idea to place threads that share a critical resource at the same priority. It has built-in FIFO scheduling, no signaling required (no semaphore, no blocking), very simple to solve critical resource sharing problems(e.g. priority inversion and deadlock)

No comments:

Post a Comment