User`s manual

Dynamic C Users Manual digi.com 71
5.9.3 Restrictions
Since a slice statement has its own stack, local auto variables and parameters cannot be accessed while
in the context of a slice statement. Any function called from the slice statement performs normally.
Only one slice statement can be active at any time, which eliminates the possibility of nesting slice
statements or using a slice statement inside a function that is either directly or indirectly called from a
slice statement. The only methods supported for leaving a slice statement are completely executing
the last statement in the slice, or executing an abort, yield or waitfor statement.
The return, continue, break, and goto statements are not supported.
Slice statements cannot be used with µC/OS-II or TCP/IP.
5.9.4 Slice Data Structure
Internally, the slice statement uses two structures to operate. When defining a named slice statement,
you supply a context buffer as the first argument. When you define an unnamed slice statement, this
structure is allocated by the compiler. Internally, the context buffer is represented by the SliceBuffer
structure below.
5.9.5 Slice Internals
When a slice statement is given control, it saves the current context and switches to a context associated
with the slice statement. After that, the driving force behind the slice statement is the timer interrupt.
Each time the timer interrupt is called, it checks to see if a slice statement is active. If a slice state-
ment is active, the timer interrupt decrements the time_out field in the slice’s SliceData. When
the field is decremented to zero, the timer interrupt saves the slice statement’s context into the
SliceBuffer and restores the previous context. Once the timer interrupt completes, the flow of control
is passed to the statement directly following the slice statement. A similar set of events takes place
when the slice statement does an explicit yield/abort/waitfor.
struct SliceData {
int time_out;
void* my_sp;
void* caller_sp;
CoData codata;
}
struct SliceBuffer {
SliceData slice_data;
char stack[]; // fills rest of the slice buffer
};