|
CX Framework
Cross-platform C utility framework
|
Functions | |
| void | osYield () |
| void | osSleep (int64 time) |
| int | osPhysicalCPUs () |
| int | osLogicalCPUs () |
| bool | osGenRandom (uint8 *buffer, uint32 size) |
Cross-platform operating system services for threading, timing, and system information. This module provides a unified interface across Windows, Unix-like systems, and WebAssembly.
The implementation is selected at compile time based on the target platform:
Available Services:
Example usage:
| bool osGenRandom | ( | uint8 * | buffer, |
| uint32 | size | ||
| ) |
Generate cryptographically secure random data.
Fills the provided buffer with random bytes from the operating system's cryptographically secure random number generator:
BCryptGenRandom/dev/urandomarc4random_buf| buffer | Buffer to fill with random data |
| size | Number of bytes to generate |
| int osLogicalCPUs | ( | ) |
Get the number of logical CPU cores.
Returns the count of logical processors, including hyperthreading cores. This is typically the number of concurrent threads the system can execute.
| int osPhysicalCPUs | ( | ) |
Get the number of physical CPU cores.
Returns the count of physical processor cores, not including hyperthreading or other logical processors.
| void osSleep | ( | int64 | time | ) |
Sleep for a specified duration.
Suspends execution of the current thread for at least the specified time. The actual sleep duration may be longer due to system scheduling.
| time | Sleep duration in microseconds |
| void osYield | ( | ) |
Yield the current thread's time slice.
Hints to the OS scheduler that the current thread should yield execution to other threads. Useful in busy-wait loops to reduce CPU usage.