4
\$\begingroup\$

The Rowley Crossworks package (includes compiler, IDE, debugging interface, etc.) also includes something called the Crossworks Tasking Library (CTL). From their website:

CrossWorks Tasking Library, known as CTL. CTL is a royalty-free tasking library that provides a multi-priority, pre-emptive, task switching and synchronisation facility. Additionally, the library can also provide timer and interrupt handling support.

I mostly understand the description of the tasking portion from my investigations into task schedulers (with the exception of synchronization... what's that mean?). However, timer and interrupt handling support has me completely thrown for a loop. Isn't that stuff built in the gcc environment (which crossworks uses btw)? Does that mean they use some kind of wrapper for the gcc syntax:

ISR(PORTB_INT0_vect)
{
    int_pin_handler();
}

If so, what advantage does it give to put that in a kernel versus just manually writing to the appropriate ports etc. as one would do in truly bare-metal programming? Finally, is it common for small OSes (I'm thinking FreeRTOS, VxWorks not linux kernels) to do this kind of thing?

Thanks

\$\endgroup\$
3
\$\begingroup\$

The point is not attaching an ISR to an interrupt, as you stated most compilers can do that.

The point is what you are allowed to do inside the ISR, especially with the synchronisation and communication primitives (flag, semaphore, queue, mailbox, etc) that the TL provides. This is tricky business, because the TL has no control over when an interrupt occurs (short of disabling interrupts, which affects the maximum interrupt latency, which is a very important figure for a TL). To strike a good balance between increased interrupt latency and forbidding ISRs to do all sorts of TL calls is one of the problems in writing a TL, henec 'support' for interrupts means that they at least have given this some thought.

\$\endgroup\$
  • \$\begingroup\$ Yikes, I'm scared by how little of your answer I understood. I will do some more research and come back with questions. \$\endgroup\$ – NickHalden Apr 2 '13 at 22:37
  • \$\begingroup\$ Can you explain what synchronisation and the other communication primitives are / why they're hard to use inside of an interrupt? Are the dangers of that similar to priority inversion? \$\endgroup\$ – NickHalden Apr 3 '13 at 1:41
  • \$\begingroup\$ Explaining flags, semaphores, etc. is a large subject, I suggsest you get a textbook about RTOSes, or a book about one of the specific RTOSes (eCOS, freeRTOS, et). The problem with an interrupt is that it can occur while the RTOS is updating some private datastructure, whih is hence temporary in an inconsistent state. Try for yourself: write code that removes an element from a double linked queue, and ask yourself what will happen, between each line of code, when the same remove function is called again. In reality it can also happen halfway a line of code. \$\endgroup\$ – Wouter van Ooijen Apr 3 '13 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.