Concurrency

condInit View Source

Returns a pointer to a new condition variable.

Outputs

A

Error code (on failure)

IX

Pointer to condition variable (on success)

Z

Set on success, reset on failure

Notes

This allocates memory for the condition variable. You should deallocate it with free when you're done.

condNotifyAll View Source

Awakens all threads waiting on a condition variable.

Inputs

IX

Pointer to condition variable

Notes

Threads awoken by this mechanism should check to see if the condition variable they were waiting for is still true.

The thread calling this function must lock the associated mutex before invoking this function, and release it afterwards.

condNotifyOne View Source

Awakens the thread that has been waiting the longest on a condition variable.

Inputs

IX

Pointer to condition variable

Notes

Threads awoken by this mechanism should check to see if the condition variable they were waiting for is still true.

The thread calling this function must lock the associated mutex before invoking this function, and release it afterwards.

condWait View Source

Blocks until another thread notifies the condition variable.

Inputs

IX

Pointer to condition variable

HL

Pointer to locked mutex

Notes

This function will enable interrupts.

You must provide a pre-initialized mutex and condition variable to this function. This function will release the mutex and suspend the thread, then awaken it when the condition variable is notified. The mutex will then be reacquired.

mutexInit View Source

Initializes a mutex byte at (HL).

Inputs

HL

Pointer to mutex byte

mutexLock View Source

Atomically locks a mutex.

Inputs

HL

Pointer to mutex byte

Notes

The application should have already initialized the mutex with initMutex.

This function blocks until the mutex is locked.

Interrupts will be enabled to do a context switch (if needed) and will be restored to their original state afterwards.

mutexUnlock View Source

Atomically unlocks a mutex.

Inputs

HL

Pointer to mutex byte

Outputs

A

Error code (on failure)

Z

Set on success, reset on failure

Notes

If the mutex is not locked already by this thread, an error will be returned.