application hangs or runs wild

Top  Previous  Next

wrong processor type given in configuration file


When you run an application, the hardware used must match the system described in your configuration file. In particular, the TYPE information on the PROCESSOR statements must correctly identify each processor.

If you have used the default processor type, check using the ProcType command that would have selected the correct processor type.

channel message has incompatible lengths


When you are sending a message through a channel, whether or not this is routed through a link to another processor, the sending and receiving sides must agree on the length of the message.

channel transfer on uninitialised channel


Before an internal channel is used, it must be initialised using the chan_init function. Note that you do not initialise channels accessed through a task's port vectors (arguments to main).

wrong header files used


Diamond has its own set of header files. These are, in general, incompatible with those supplied with the Texas Instruments C compiler. To make sure the compiler picks up the correct header files, you should use the Diamond command (3L C) to compile programs.

function prototypes necessary


You must supply a prototype for any function to which you wish to make external or forward references. If you do not do this, the compiler may generate the wrong code for the function call, but even so it may not report an error. This is particularly serious if the function has a variable number of parameters (printf, for example). You should always include header files for library functions.

ill-advised alterations to CPU registers


You should not change any of the CPU registers if you are uncertain about what you are doing. It is easily possible to disrupt the microkernel in this way.

multiple use of run-time library


Several parts of the run-time library cannot be used by more than one thread from the same task at a time. In a multi-threaded task, you should wait for the semaphore par_sema before using the run-time library, or use the special protected versions of certain functions which are defined in par.h. You do not need to protect calls from different tasks in this way.

multiple use of shared object


If two or more threads are using the same data area, link, etc, it should be protected by a semaphore or by some other technique, to ensure that conflicting accesses do not occur.

no memory assigned to STACK or HEAP


If you assign a size to either the HEAP or STACK logical area in a TASK statement in your configuration, but do not assign a size to the other, the other is given no memory. Nearly all tasks  fail under these conditions.

 

Either assign values to both or use the DATA logical area, which is shared by the two of them. One task on each processor may have no data assignments; this task is given all the available remaining memory for its DATA logical area.

not enough memory assigned to logical area


If the stack or heap overflows its assigned memory area, the application usually fails.

tried to turn interrupts off


Diamond applications usually run with processor interrupts turned on. Turning interrupts off at the wrong time often prevents your application from running.

two threads waiting on one channel


If a thread tries to do a read on a channel, the thread waits until another thread does a write on it; at that moment, the transfer takes place. If, during the time the thread is waiting for the transfer to happen, a third thread tries to do a read on the same channel, the effects are unpredictable.

 

The same applies if a thread tries to do a write on a channel and is waiting for another thread to read the data; if a third thread tries to write to the channel, the effects are unpredictable.

uninitialised semaphore


You must always initialise a semaphore, dynamically using the sema_init function or statically using static_sema_init, before using any other function on it.

 

Note that the run-time library initialises par_sema for you.

uninitialised event


You must always initialise an event before using any other function on it.

failing to claim a DMA channel


Diamond can claim and release DMA channels dynamically. If you use a channel without first claiming it, another part of your application may be given that same channel to use, leading to undefined behaviour. Diamond itself only ever uses DMA channels corresponding to the four external interrupt lines: INT4–INT7, but application code is free to use any.

duplicate channel in alt function


The channel arguments in the alt functions must be unique within that call; no channel may appear more than once in the list. You may refer to the same channels in different alt function calls.