PKUOS - Pintos
Pintos source browser for PKU Operating System course
Functions
random.h File Reference
#include <stddef.h>
Include dependency graph for random.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void random_init (unsigned seed)
 Initializes or reinitializes the PRNG with the given SEED. More...
 
void random_bytes (void *, size_t)
 Writes SIZE random bytes into BUF. More...
 
unsigned long random_ulong (void)
 lib/random.h More...
 

Function Documentation

◆ random_bytes()

void random_bytes ( void *  buf_,
size_t  size 
)

Writes SIZE random bytes into BUF.

Definition at line 54 of file random.c.

References buf, inited, random_init(), s, s_i, s_j, and swap_byte().

Referenced by main(), random_ulong(), seq_test(), and test_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_init()

void random_init ( unsigned  seed)

Initializes or reinitializes the PRNG with the given SEED.

Definition at line 34 of file random.c.

References inited, s, s_i, s_j, and swap_byte().

Referenced by consume_some_resources_and_die(), main(), parse_options(), random_bytes(), and test_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_ulong()

unsigned long random_ulong ( void  )

lib/random.h

lib/random.h

Use random_ulong() % n to obtain a random number in the range 0...n (exclusive).

Definition at line 78 of file random.c.

References random_bytes().

Referenced by consume_some_resources_and_die(), expand(), pick_pivot(), shuffle(), test(), and write_some_bytes().

Here is the call graph for this function:
Here is the caller graph for this function: