#endif
// === CONSTANTS ===
-#define RANDOM_SEED 0xACE55052
#define SWITCH_MAGIC 0xFFFACE55 // There is no code in this area
#define DEFAULT_QUANTUM 10
#define DEFAULT_TICKETS 5
/**
* \fn Uint Proc_MakeUserStack()
+ * \brief Creates a new user stack
*/
Uint Proc_MakeUserStack()
{
/**
* \fn void Proc_DumpThreads()
+ * \brief Dums a list of currently running threads
*/
void Proc_DumpThreads()
{
/**
* \fn void Proc_Scheduler(int CPU)
- * \brief Swap current task
+ * \brief Swap current thread and clears dead threads
*/
void Proc_Scheduler(int CPU)
{
{
return gCurrentThread->GID;
}
-
-/**
- * \fn Uint rand()
- * \brief Pseudo random number generator
- * \note Unknown effectiveness (made up on the spot)
- */
-Uint rand()
-{
- static Uint randomState = RANDOM_SEED;
- Uint ret = randomState;
- int roll = randomState & 31;
- randomState = (randomState << roll) | (randomState >> (32-roll));
- randomState ^= 0x9A3C5E78;
- return ret;
-}
#include <common.h>
// === CONSTANTS ===
+#define RANDOM_SEED 0xACE55052
+#define RANDOM_A 0x12231ADE
+#define RANDOM_C 0x1BADBEEF
// Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec
const short DAYS_BEFORE[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
#define UNIX_TO_2K ((30*365*3600*24) + (7*3600*24)) //Normal years + leap years
return stamp * 1000;
}
+/**
+ * \fn Uint rand()
+ * \brief Pseudo random number generator
+ * \note Unknown effectiveness (made up on the spot)
+ */
+Uint rand()
+{
+ #if 0
+ static Uint randomState = RANDOM_SEED;
+ Uint ret = randomState;
+ int roll = randomState & 31;
+ randomState = (randomState << roll) | (randomState >> (32-roll));
+ randomState ^= 0x9A3C5E78;
+ return ret;
+ #else
+ static Uint randomState = RANDOM_SEED;
+ return randomState = (RANDOM_A*randomState + RANDOM_C) & 0xFFFFFFFF;
+ #endif
+}
+
EXPORT(timestamp);
EXPORT(ReadUTF8);