BOOL osCloseHandle( HANDLE Handle );
The handle of the object to be closed.
TRUE on success or FALSE on failure. Call the osGetLastError function to obtain extended error information.
When an object is created, the system returns a handle used to identify the object during subsequent operations. Once an object is no longer required, its handle must be closed to facilitate object deletion. An object is physically deleted from the system only when all tasks that have opened it call osCloseHandle.
Created objects can be shared between multiple tasks. If an object is deleted while an operation is still in progress, it may lead to unpredictable behavior or system failure. To prevent this, each task must explicitly open the object using either an osOpen* function or the osOpenByHandle function. The system maintains a reference count and ensures the object is only destroyed after every task that opened it has issued a corresponding close command.
If an object is never intended to be deleted by other tasks, explicitly opening it is unnecessary. If the application design guarantees that no objects will be removed during runtime, OS_ALLOW_OBJECT_DELETION should be set to 0. In this configuration, the osCloseHandle function is unavailable, and osOpen* functions return the object handle without performing formal "open" tracking. This reduces system resource consumption and the final code footprint.
| Version: | 1.0 |
|---|---|
| Header file: | OS_API.h |
| See also: | BOOL, FALSE, HANDLE, osOpenByHandle, osGetLastError, system objects management, TRUE |