Sync.asm

This file contains basic synchronization and mutual exclusion functions of PwnOS.

See Also

  • Sync
  • <SyncScheduling.asm>

Authors

  • Neil G.  Dickson
Summary
Sync.asmThis file contains basic synchronization and mutual exclusion functions of PwnOS.
Functions
GetLockThis procedure gets a lock’s access for the current thread.
ReleaseLockThis procedure releases a lock so that other threads can get it.
AttemptGetLockThis procedure attempts to get a lock, but if it cannot get a lock, it gives up after a specified timeout period.
WaitForNotifyThis procedure makes the current thread wait to be notified on the specified lock.
AttemptWaitForNotifyThis procedure makes the current thread wait to be notified on the specified lock until a specified timeout period elapses.
NotifyThis procedure notifies a thread waiting on the specified lock (if there is one).
NotifyAllThis procedure notifies all threads waiting on the specified lock (if there are any).
Gateway Functions of Sync.asm
Functions
GetLockUGateway function for GetLock
ReleaseLockUGateway function for ReleaseLock
AttemptGetLockUGateway function for AttemptGetLock
WaitForNotifyUGateway function for WaitForNotify
AttemptWaitForNotifyUGateway function for AttemptWaitForNotify
NotifyUGateway function for Notify
NotifyAllUGateway function for NotifyAll

Functions

GetLock

This procedure gets a lock’s access for the current thread.  It does not return until the current thread gets the lock.

TODO: Check priorities instead of just putting current thread at beginning of access list, or leave to ReleaseLock

Parameters

pLockaddress of lock sturcture

ReleaseLock

This procedure releases a lock so that other threads can get it.

If the current thread doesn’t have the specified lock, this procedure does nothing.

Parameters

pLockaddress of lock sturcture

AttemptGetLock

This procedure attempts to get a lock, but if it cannot get a lock, it gives up after a specified timeout period.

Not Implemented

Parameters

pLockaddress of lock sturcture
timeouttime (in milliseconds) for which to attempt before giving up

Returns

  • TRUE if the lock access was obtained, otherwise FALSE

WaitForNotify

This procedure makes the current thread wait to be notified on the specified lock.

If the current thread doesn’t have the specified lock, this procedure does nothing.  The lock is released before going to the thread scheduler.

Parameters

pLockaddress of lock sturcture

AttemptWaitForNotify

This procedure makes the current thread wait to be notified on the specified lock until a specified timeout period elapses.

Not Implemented

Parameters

pLockaddress of lock sturcture
timeouttime (in milliseconds) for which to wait before giving up

Returns

  • TRUE if the notify was received, otherwise FALSE

Notify

This procedure notifies a thread waiting on the specified lock (if there is one).

If the current thread doesn’t have the specified lock or no threads are waiting for notify, this procedure does nothing.

Parameters

pLockaddress of lock sturcture

NotifyAll

This procedure notifies all threads waiting on the specified lock (if there are any).

If the current thread doesn’t have the specified lock or no threads are waiting for notify, this procedure does nothing.

Parameters

pLockaddress of lock sturcture

Gateway Functions of Sync.asm

Summary
Functions
GetLockUGateway function for GetLock
ReleaseLockUGateway function for ReleaseLock
AttemptGetLockUGateway function for AttemptGetLock
WaitForNotifyUGateway function for WaitForNotify
AttemptWaitForNotifyUGateway function for AttemptWaitForNotify
NotifyUGateway function for Notify
NotifyAllUGateway function for NotifyAll

Functions

GetLockU

Gateway function for GetLock

This checks that the LOCKSTRUCT isn’t in system space.

ReleaseLockU

Gateway function for ReleaseLock

This checks that the LOCKSTRUCT isn’t in system space.

AttemptGetLockU

Gateway function for AttemptGetLock

This checks that the LOCKSTRUCT isn’t in system space.

WaitForNotifyU

Gateway function for WaitForNotify

This checks that the LOCKSTRUCT isn’t in system space.

AttemptWaitForNotifyU

Gateway function for AttemptWaitForNotify

This checks that the LOCKSTRUCT isn’t in system space.

NotifyU

Gateway function for Notify

This checks that the LOCKSTRUCT isn’t in system space.

NotifyAllU

Gateway function for NotifyAll

This checks that the LOCKSTRUCT isn’t in system space.

This procedure gets a lock’s access for the current thread.
This procedure releases a lock so that other threads can get it.
This procedure attempts to get a lock, but if it cannot get a lock, it gives up after a specified timeout period.
This procedure makes the current thread wait to be notified on the specified lock.
This procedure makes the current thread wait to be notified on the specified lock until a specified timeout period elapses.
This procedure notifies a thread waiting on the specified lock (if there is one).
This procedure notifies all threads waiting on the specified lock (if there are any).
The Sync section of Core provides functions for mutual exclusion.
This structure is the centre of synchronization data in PwnOS, defining the state of an access lock.