Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

rk_stub.c File Reference


Detailed Description

The implementation of the resource kernel (rk) simulator.

Definition in file rk_stub.c.

Include dependency graph for rk_stub.c:

Include dependency graph

Go to the source code of this file.

Defines

#define max(x, y)   ((x) > (y) ? (x) : (y))
 Return the maximum of two values.

#define min(x, y)   ((x) < (y) ? (x) : (y))
 Return the minimum of two values.


Functions

void rk_cpu_reserve_tick (rk_resource_set_t rs, cpu_reserve_t cr, struct timespec *curr, struct timespec *next, struct timespec *new_compute)
 Function used to advance simulated time.

int rk_name_valid (const char *name)
 Validate a user provided name value.

int rk_reserve_mode_valid (rk_reserve_mode_t rm)
 Validate a user provided rk_reserve_mode_t value.

int rk_reserve_param_valid (rk_reserve_param_t rp)
 Validate a user provided rk_reserve_param_t value.

int rk_cpu_reserve_attr_valid (cpu_reserve_attr_t ra_in)
 Validate a user provided cpu_reserve_attr_t value.

int cpu_reserve_valid (cpu_reserve_t cr)
 Validate a user provided cpu_reserve_t value.

int rk_resource_set_valid (rk_resource_set_t rs)
 Validate a user provided rk_resource_set_t value.

char * rk_reserve_mode_string (rk_reserve_mode_t rm)
 Get the string version of an rk_reserve_mode_t value.

char * rk_reserve_param_string (rk_reserve_param_t rp)
 Get the string version of an rk_reserve_param_t value.

char * cpu_reserve_attr_string (cpu_reserve_attr_t ra)
 Get the string version of a cpu_reserve_attr_t value.

char * cpu_reserve_string (cpu_reserve_t cr)
 Get the string version of a cpu_reserve_t value.

char * rk_resource_set_string (rk_resource_set_t rs)
 Get the string version of a rk_resource_set_t value.

char * rk_stub_pcb_string (pid_t pid)
 Get the string version of a simulated pid_t value.

void rk_inherit_mode (int dummy)
 Not implemented.

int rk_resource_sets_get_list (rk_resource_set_t *rs_inout, int count)
 Query the system for the list of mock resource sets.

int rk_resource_sets_get_num (void)
rk_resource_set_t rk_resource_set_create (const char *name)
 Construct a mock resource set with the given name.

int rk_resource_set_destroy (rk_resource_set_t rs)
 Destroy a resource set.

int rk_resource_set_set_name (rk_resource_set_t rs, const char *name)
 Set the name of a resource set.

int rk_resource_set_get_name (rk_resource_set_t rs, char *name_out)
 Get the name of a resource set.

rk_reserve_t rk_resource_set_get_cpu_rsv (rk_resource_set_t rs)
 Get the CPU reserve from the given resource set.

int rk_resource_set_attach_process (rk_resource_set_t rs, pid_t pid)
 Attach a process to the resource set so that its callbacks will be used when a data period is starting/ending.

int rk_resource_set_detach_process (rk_resource_set_t rs, pid_t pid)
 Detach a process from the resource set.

int rk_resource_set_get_num_procs (rk_resource_set_t rs)
int rk_resource_set_get_proclist (rk_resource_set_t rs, pid_t *procs_inout, int count)
 Query the system for the list of processes attached to the given resource set.

rk_resource_set_t rk_proc_get_rset (pid_t pid)
 Get the resource set attached to the given process.

int rk_cpu_reserve_create (rk_resource_set_t rs, rk_reserve_t *r_out, cpu_reserve_attr_t ra_in)
 Create a CPU reserve for the given resource set.

int rk_cpu_reserve_delete (rk_resource_set_t rs)
 Delete a CPU reserve held by a resource set.

int rk_cpu_reserve_get_attr (rk_reserve_t cr, cpu_reserve_attr_t ra_out)
 Get the reservation parameters for a given CPU reserve.

int rk_cpu_reserve_ctl (rk_resource_set_t rs, cpu_reserve_attr_t ra_in)
 Change a CPU reserve's scheduling parameters.

int rk_clock_gettime (clockid_t clock_id, struct timespec *ts)
 Get the simulator's virtual time.

int rk_clock_settime (clockid_t clock_id, struct timespec *ts)
 Set the simulator's virtual time.

int rk_clock_getres (clockid_t clock_id, struct timespec *ts)
 Get the simulator's virtual clock resolution.

void rk_stub_set_mode (rk_stub_mode_t mode)
 Initialize the stub code and set the desired mode.

void rk_next_tick (struct timespec *next, struct timespec *curr, struct timespec *new_next)
 Verify time values and update the next time value if an earlier time is seen.

void rk_stub_next_tick (void)
 Advance the simulated time.

pid_t rk_stub_mk_pid (const char *name, void *data, rk_stub_precall_t precall, rk_stub_postcall_t postcall)
 Make a simulated process that will "consume" resources during its period.

void rk_stub_getrusage (pid_t pid, struct rusage *ru)
 Get the CPU usage for the simulated process.


Variables

rk_stub_data rk_stub_data
 Global data for the rk_stub functions.

char * rk_cpu_trace_names [RK_CPU_TRACE_MAX]
 The string forms of the trace file enumeration.


Function Documentation

char* cpu_reserve_attr_string cpu_reserve_attr_t  ra  )  [static]
 

Get the string version of a cpu_reserve_attr_t value.

Parameters:
ra The cpu_reserve_attr_t to stringify or NULL.
Returns:
A statically allocated string formatted with the values in the parameter.

Definition at line 304 of file rk_stub.c.

References cpu_reserve_attr::blocking_time, cpu_reserve_attr::compute_time, cpu_reserve_attr_t, cpu_reserve_attr::deadline, cpu_reserve_attr::period, cpu_reserve_attr::processor, cpu_reserve_attr::reserve_type, rk_reserve_param_string(), and cpu_reserve_attr::start_time.

Referenced by cpu_reserve_string(), rk_cpu_reserve_create(), rk_cpu_reserve_ctl(), and rk_cpu_reserve_get_attr().

Here is the call graph for this function:

char* cpu_reserve_string cpu_reserve_t  cr  )  [static]
 

Get the string version of a cpu_reserve_t value.

Parameters:
cr The cpu_reserve_t to stringify or NULL.
Returns:
A statically allocated string formatted with the values in the parameter.

Definition at line 346 of file rk_stub.c.

References cpu_reserve_attr_string(), and cpu_reserve_t.

Referenced by rk_cpu_reserve_create(), rk_cpu_reserve_get_attr(), and rk_resource_set_string().

Here is the call graph for this function:

int cpu_reserve_valid cpu_reserve_t  cr  )  [static]
 

Validate a user provided cpu_reserve_t value.

Validation is done by checking the pointer against the internal list of resource sets.

Parameters:
cr The cpu_reserve_t to validate.
Returns:
True if the parameter is valid, false otherwise.

Definition at line 193 of file rk_stub.c.

References cpu_reserve_t, require, rk_resource_set_t, and rk_stub_data.

Referenced by rk_cpu_reserve_create(), rk_cpu_reserve_delete(), rk_cpu_reserve_get_attr(), and rk_resource_set_get_cpu_rsv().

int rk_clock_getres clockid_t  clock_id,
struct timespec *  ts
 

Get the simulator's virtual clock resolution.

Parameters:
clock_id The clock type, only CLOCK_REALTIME is supported.
ts The timespec object to fill out.
Returns:
Zero if the query was successful, otherwise it returns -1 and sets errno appropriately.

Definition at line 1296 of file rk_stub.c.

References NANOS_PER_MICRO.

int rk_clock_gettime clockid_t  clock_id,
struct timespec *  ts
 

Get the simulator's virtual time.

Parameters:
clock_id The clock type, only CLOCK_REALTIME is supported.
ts The timespec object to fill out.
Returns:
Zero if the query was successful, otherwise it returns -1 and sets errno appropriately.

Definition at line 1256 of file rk_stub.c.

References rk_stub_data.

Referenced by BasicDelegate::postcall(), and BasicDelegate::precall().

int rk_clock_settime clockid_t  clock_id,
struct timespec *  ts
 

Set the simulator's virtual time.

This function should really only be used to set the time to a value _before_ the next event.

Parameters:
clock_id The clock type, only CLOCK_REALTIME is supported.
ts The new virtual time value.
Returns:
Zero if the query was successful, otherwise it returns -1 and sets errno appropriately.

Definition at line 1276 of file rk_stub.c.

References rk_stub_data.

int rk_cpu_reserve_attr_valid cpu_reserve_attr_t  ra_in  )  [static]
 

Validate a user provided cpu_reserve_attr_t value.

A valid reserve must have the following attributes:

  • period >= RT_MIN_PERIOD
  • compute_time <= deadline
  • deadline > 0
  • deadline <= period
  • rk_reserve_param_valid(reserve_type) == 1
Parameters:
ra_in The cpu_reserve_attr_t to validate.
Returns:
True if the parameter is valid, false otherwise.

Definition at line 166 of file rk_stub.c.

References cpu_reserve_attr::compute_time, cpu_reserve_attr_t, cpu_reserve_attr::deadline, cpu_reserve_attr::period, require, cpu_reserve_attr::reserve_type, rk_reserve_param_valid(), RT_MIN_PERIOD, and tscmp.

Referenced by rk_cpu_reserve_create(), rk_cpu_reserve_ctl(), and rk_cpu_reserve_get_attr().

Here is the call graph for this function:

int rk_cpu_reserve_create rk_resource_set_t  rs,
rk_reserve_t r_out,
cpu_reserve_attr_t  ra_in
 

Create a CPU reserve for the given resource set.

In order to simulate this reserve, a "times" file must be available in the current directory. The contents of the file should be a whitespace separated list of floats that specify the percentage of CPU time required by the process for a repeating sequence of periods. For example, the times file for a resource set named "steady_50" that required 50% of the CPU at every period would be named "steady_50_cpu_times" and contain only "50.0". Another, more complex example, would be a reserve that oscillated between 10% and 50% with 10% steps would contain "10.0 20.0 30.0 40.0 50.0 40.0 30.0 20.0 10.0".

The output of CPU simulation is a set of files that can be fed into gnuplot. The contents of the file are two columns of numbers, a time value, and a CPU percentage or an arbitrary value that marks some event. The current list of files is:

  • _cpu_period The CPU reserve's period.
  • _cpu_deadline The CPU reserve's deadline.
  • _cpu_complete Marks the completion of a data period.
  • _cpu_drop Marks a data period as being dropped.
  • _cpu_realtime The CPU time required by the process.
  • _cpu_success The actual CPU time received by a process that is making its deadlines.
  • _cpu_fail The actual CPU time received by a process that is missing its deadlines.
Parameters:
rs The resource set that will hold the CPU reserve.
r_out A pointer that can be set to the new CPU reserve.
ra_in The reservation parameters.
Returns:
Zero if the reserve was created successfully, an errno value otherwise.

Definition at line 924 of file rk_stub.c.

References cpu_reserve_attr_string(), cpu_reserve_attr_t, cpu_reserve_string(), cpu_reserve_t, cpu_reserve_valid(), cpu_reserve_attr::deadline, ensure, microsec_to_timespec(), require, rk_cpu_reserve_attr_valid(), rk_cpu_reserve_delete(), rk_cpu_trace_names, rk_reserve_t, rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), rk_stub_data, RK_STUB_LOG, RK_STUB_SIM, RSET_NAME_LEN, and timespec_to_microsec().

Referenced by RKTask::BeginCPUScheduling(), rktCreateSelfResourceSet(), rktGetChildResourceSet(), and server_main().

Here is the call graph for this function:

int rk_cpu_reserve_ctl rk_resource_set_t  rs,
cpu_reserve_attr_t  ra_in
 

Change a CPU reserve's scheduling parameters.

Parameters:
rs The CPU reserve to change.
ra_in The new scheduling parameters.
Returns:
Zero if the change was successful, an errno value otherwise.

Definition at line 1198 of file rk_stub.c.

References cpu_reserve_attr::compute_time, cpu_reserve_attr_string(), cpu_reserve_attr_t, cpu_reserve_t, require, rk_cpu_reserve_attr_valid(), rk_cpu_reserve_tick(), rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), rk_stub_data, and tscmp.

Referenced by RKTask::SetComputeTime().

Here is the call graph for this function:

int rk_cpu_reserve_delete rk_resource_set_t  rs  ) 
 

Delete a CPU reserve held by a resource set.

Parameters:
rs A resource set.
Returns:
Zero on success, -1 on error.

Definition at line 1114 of file rk_stub.c.

References cpu_reserve_t, cpu_reserve_valid(), ensure, require, rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), and rk_stub_data.

Referenced by RKTask::BeginCPUScheduling(), rk_cpu_reserve_create(), rk_resource_set_destroy(), and rktGetChildResourceSet().

Here is the call graph for this function:

int rk_cpu_reserve_get_attr rk_reserve_t  cr,
cpu_reserve_attr_t  ra_out
 

Get the reservation parameters for a given CPU reserve.

Parameters:
cr The CPU reserve to query.
ra_out The cpu_reserve_attr object to fill with the CPU reserve's current parameters.
Returns:
Zero if the query was successful, an errno value otherwise.

Definition at line 1168 of file rk_stub.c.

References cpu_reserve_attr_string(), cpu_reserve_attr_t, cpu_reserve_string(), cpu_reserve_t, cpu_reserve_valid(), ensure, require, rk_cpu_reserve_attr_valid(), rk_reserve_t, and rk_stub_data.

Referenced by sigalrm().

Here is the call graph for this function:

void rk_cpu_reserve_tick rk_resource_set_t  rs,
cpu_reserve_t  cr,
struct timespec *  curr,
struct timespec *  next,
struct timespec *  new_compute
[static]
 

Function used to advance simulated time.

Parameters:
rs The resource set that has processes that will consume resources.
cr The cpu_reserve_t of the resource set.
curr The current time.
next The next time a simulated event will occur.
new_compute NULL or the resource set's new computation time.

Definition at line 1371 of file rk_stub.c.

References cpu_reserve_t, ensure, max, microsec_to_timespec(), NANOS_PER_MICRO, require, RK_CPU_TRACE_COMPLETE, RK_CPU_TRACE_COMPUTE_FAIL, RK_CPU_TRACE_COMPUTE_SUCCESS, RK_CPU_TRACE_DEADLINE, RK_CPU_TRACE_DROP, RK_CPU_TRACE_PERIOD, RK_CPU_TRACE_REALTIME, rk_next_tick(), rk_resource_set_t, rk_stub_data, rk_stub_precall_t, RKSP_DROP, and timespec_to_microsec().

Referenced by rk_cpu_reserve_ctl(), and rk_stub_next_tick().

Here is the call graph for this function:

int rk_name_valid const char *  name  )  [static]
 

Validate a user provided name value.

Currently, the only test is whether or not the name is printable.

Parameters:
name The name to validate.
Returns:
True if the parameter is valid, false otherwise.

Definition at line 91 of file rk_stub.c.

References require.

Referenced by rk_resource_set_create(), and rk_resource_set_set_name().

void rk_next_tick struct timespec *  next,
struct timespec *  curr,
struct timespec *  new_next
[static]
 

Verify time values and update the next time value if an earlier time is seen.

Parameters:
next The next simulated time value.
curr The current time.
new_next An event time.

Definition at line 1348 of file rk_stub.c.

References require, and tscmp.

Referenced by rk_cpu_reserve_tick().

rk_resource_set_t rk_proc_get_rset pid_t  pid  ) 
 

Get the resource set attached to the given process.

Parameters:
pid The fake process ID to query.
Returns:
The resource set that is attached to the process or NULL if none is attached.

Definition at line 891 of file rk_stub.c.

References ensure, MAX_PCB, NULL_RESOURCE_SET, require, rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), rk_stub_data, and rk_stub_pcb_string().

Referenced by RKTask::BeginCPUScheduling(), paGetAdvocate(), rk_resource_set_attach_process(), and rk_resource_set_detach_process().

Here is the call graph for this function:

char* rk_reserve_mode_string rk_reserve_mode_t  rm  )  [static]
 

Get the string version of an rk_reserve_mode_t value.

Parameters:
rm The rk_reserve_mode_t to stringify.
Returns:
A statically allocated string that corresponds to the parameter.

Definition at line 248 of file rk_stub.c.

References RSV_FIRM, RSV_HARD, and RSV_SOFT.

Referenced by rk_reserve_param_string().

int rk_reserve_mode_valid rk_reserve_mode_t  rm  )  [static]
 

Validate a user provided rk_reserve_mode_t value.

The only valid values are listed in the enumeration.

Parameters:
rm The rk_reserve_mode_t to validate.
Returns:
True if the parameter is valid, false otherwise.

Definition at line 111 of file rk_stub.c.

References RSV_FIRM, RSV_HARD, and RSV_SOFT.

Referenced by rk_reserve_param_valid().

char* rk_reserve_param_string rk_reserve_param_t  rp  )  [static]
 

Get the string version of an rk_reserve_param_t value.

Parameters:
rp The rk_reserve_param_t to stringify or NULL.
Returns:
A statically allocated string formatted with the values in the parameter.

Definition at line 277 of file rk_stub.c.

References rk_reserve_param::enf_mode, rk_reserve_param::rep_mode, rk_reserve_mode_string(), rk_reserve_param_t, and rk_reserve_param::sch_mode.

Referenced by cpu_reserve_attr_string().

Here is the call graph for this function:

int rk_reserve_param_valid rk_reserve_param_t  rp  )  [static]
 

Validate a user provided rk_reserve_param_t value.

A valid rk_reserve_param_t must have the following attributes:

  • rk_reserve_mode_valid(sch_mode) == 1
  • rk_reserve_mode_valid(enf_mode) == 1
  • rk_reserve_mode_valid(rep_mode) == 1
Parameters:
rp The rk_reserve_param_t to validate.
Returns:
True if the parameter is valid, false otherwise.

Definition at line 140 of file rk_stub.c.

References rk_reserve_param::enf_mode, rk_reserve_param::rep_mode, rk_reserve_mode_valid(), rk_reserve_param_t, and rk_reserve_param::sch_mode.

Referenced by rk_cpu_reserve_attr_valid().

Here is the call graph for this function:

int rk_resource_set_attach_process rk_resource_set_t  rs,
pid_t  pid
 

Attach a process to the resource set so that its callbacks will be used when a data period is starting/ending.

Note: The simulator only supports one process being attached at a time.

Parameters:
rs The resource set that will be attached to the process.
pid The fake process ID to attach to the resource set.
Returns:
Zero if the process was successfully attached, an errno value otherwise.

Definition at line 739 of file rk_stub.c.

References ensure, MAX_PCB, require, rk_proc_get_rset(), rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), rk_stub_data, rk_stub_pcb_string(), and RK_STUB_SIM.

Referenced by RKTask::BeginCPUScheduling(), rktChildPart(), rktParentPart(), and server_main().

Here is the call graph for this function:

rk_resource_set_t rk_resource_set_create const char *  name  ) 
 

Construct a mock resource set with the given name.

The name has special meaning in the simulator, it will be used as the base for any files that are produced or read by the stub code. For example, a file produced or read by the CPU reserve will use file names of the form: <name>_cpu_<file-type>.

See also:
rk_cpu_reserve_create

rk_cpu_reserve_trace_t

Parameters:
name The name for the resource set.
Returns:
A new rk_resource_set_t object or NULL if the creation failed.

Definition at line 548 of file rk_stub.c.

References ensure, lnAddTail(), NULL_RESOURCE_SET, require, rk_name_valid(), rk_resource_set_t, rk_resource_set_valid(), rk_stub_data, and RSET_NAME_LEN.

Referenced by RKTask::BeginCPUScheduling(), rktCreateSelfResourceSet(), rktGetChildResourceSet(), and server_main().

Here is the call graph for this function:

int rk_resource_set_destroy rk_resource_set_t  rs  ) 
 

Destroy a resource set.

Parameters:
rs The resource set to destroy.

Definition at line 595 of file rk_stub.c.

References ensure, lnRemove(), require, rk_cpu_reserve_delete(), rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), and rk_stub_data.

Referenced by RKTask::BeginCPUScheduling(), RKTask::EndCPUScheduling(), rktCreateSelfResourceSet(), rktRepairResourceSets(), server_main(), sig_exit_handler(), and sigexit_handler().

Here is the call graph for this function:

int rk_resource_set_detach_process rk_resource_set_t  rs,
pid_t  pid
 

Detach a process from the resource set.

Parameters:
rs The attached resource set.
pid The fake process ID to detach from the resource set.
Returns:
Zero if the process was successfully detached, an errno value otherwise.

Definition at line 783 of file rk_stub.c.

References ensure, MAX_PCB, require, rk_proc_get_rset(), rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), rk_stub_data, and rk_stub_pcb_string().

Here is the call graph for this function:

rk_reserve_t rk_resource_set_get_cpu_rsv rk_resource_set_t  rs  ) 
 

Get the CPU reserve from the given resource set.

Parameters:
rs The resource set to query.
Returns:
A pointer to the CPU reserve or NULL if the resource set did not have a CPU reserve attached.

Definition at line 706 of file rk_stub.c.

References cpu_reserve_valid(), ensure, NULL_RESERVE, require, rk_reserve_t, rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), and rk_stub_data.

Referenced by RKTask::BeginCPUScheduling(), rktGetChildResourceSet(), rktRepairResourceSets(), and sigalrm().

Here is the call graph for this function:

int rk_resource_set_get_name rk_resource_set_t  rs,
char *  name_out
 

Get the name of a resource set.

Parameters:
rs The resource set to query.
name_out The character array, of atleast RSET_NAME_LEN length, to fill out with the name of the resource set.
Returns:
Zero if the parameters were valid, an errno value otherwise.

Definition at line 673 of file rk_stub.c.

References ensure, require, rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), rk_stub_data, and RSET_NAME_LEN.

Referenced by rk_resource_set_get_by_name().

Here is the call graph for this function:

int rk_resource_set_get_num_procs rk_resource_set_t  rs  ) 
 

Parameters:
rs The resource set to query.
Returns:
The number of processes attached to the given resource set.

Definition at line 822 of file rk_stub.c.

References NULL_RESOURCE_SET, require, rk_resource_set_string(), rk_resource_set_t, and rk_stub_data.

Referenced by RKTask::BeginCPUScheduling(), rktGetChildResourceSet(), and rktRepairResourceSets().

Here is the call graph for this function:

int rk_resource_set_get_proclist rk_resource_set_t  rs,
pid_t *  procs_inout,
int  count
 

Query the system for the list of processes attached to the given resource set.

Note: The simulator only supports one process being attached at a time.

Parameters:
rs The resource set to query for attached processes.
procs_inout An array that can hold atleast 'count' pid_t elements.
count The size of the 'procs_inout' array.
Returns:
The actual number of elements in the 'procs_inout' array that were filled in with pid's.

Definition at line 852 of file rk_stub.c.

References NULL_RESOURCE_SET, require, rk_resource_set_string(), rk_resource_set_t, and rk_stub_data.

Referenced by rk_resource_set_get_usage(), and sigalrm().

Here is the call graph for this function:

int rk_resource_set_set_name rk_resource_set_t  rs,
const char *  name
 

Set the name of a resource set.

This is provided for compatibility and is otherwise unwise to use since the name has meaning in the simulation code.

Parameters:
rs The resource set to rename.
name The new name.
Returns:
Zero if the name was valid, an errno value otherwise.

Definition at line 629 of file rk_stub.c.

References ensure, require, rk_name_valid(), rk_resource_set_string(), rk_resource_set_t, rk_resource_set_valid(), rk_stub_data, and RSET_NAME_LEN.

Here is the call graph for this function:

char* rk_resource_set_string rk_resource_set_t  rs  )  [static]
 

Get the string version of a rk_resource_set_t value.

Parameters:
rs The rk_resource_set_t to stringify or NULL.
Returns:
A statically allocated string formatted with the values in the parameter.

Definition at line 399 of file rk_stub.c.

References cpu_reserve_string(), rk_resource_set_t, and rk_resource_set_valid().

Referenced by rk_cpu_reserve_create(), rk_cpu_reserve_ctl(), rk_cpu_reserve_delete(), rk_proc_get_rset(), rk_resource_set_attach_process(), rk_resource_set_destroy(), rk_resource_set_detach_process(), rk_resource_set_get_cpu_rsv(), rk_resource_set_get_name(), rk_resource_set_get_num_procs(), rk_resource_set_get_proclist(), and rk_resource_set_set_name().

Here is the call graph for this function:

int rk_resource_set_valid rk_resource_set_t  rs  )  [static]
 

Validate a user provided rk_resource_set_t value.

Validation is done by checking the pointer against the internal list of resource sets.

Parameters:
rs The rk_resource_set_t to validate.
Returns:
True if the parameter is valid, false otherwise.

Definition at line 219 of file rk_stub.c.

References require, rk_resource_set_t, and rk_stub_data.

Referenced by rk_cpu_reserve_create(), rk_cpu_reserve_ctl(), rk_cpu_reserve_delete(), rk_proc_get_rset(), rk_resource_set_attach_process(), rk_resource_set_create(), rk_resource_set_destroy(), rk_resource_set_detach_process(), rk_resource_set_get_cpu_rsv(), rk_resource_set_get_name(), rk_resource_set_set_name(), and rk_resource_set_string().

int rk_resource_sets_get_list rk_resource_set_t rs_inout,
int  count
 

Query the system for the list of mock resource sets.

Parameters:
rs_inout An array that can hold atleast 'count' rk_resource_set_t elements.
count The size of the 'rs_inout' array.
Returns:
The actual number of elements in the 'rs_inout' array that were filled in with resource set pointers.

Definition at line 486 of file rk_stub.c.

References require, rk_resource_set_t, and rk_stub_data.

Referenced by rk_resource_set_get_by_name(), and rktRepairResourceSets().

int rk_resource_sets_get_num void   ) 
 

Returns:
The number of mock resource sets that are currently active.

Definition at line 525 of file rk_stub.c.

References require, and rk_stub_data.

void rk_stub_getrusage pid_t  pid,
struct rusage *  ru
 

Get the CPU usage for the simulated process.

Parameters:
pid The process(es) to query for usage information.
ru The rusage object to fill out.
Returns:
Zero if the query was successful, otherwise it returns -1 and sets errno appropriately.

Definition at line 1942 of file rk_stub.c.

References MAX_PCB, require, and rk_stub_data.

Referenced by BasicDelegate::postcall(), and BasicDelegate::precall().

pid_t rk_stub_mk_pid const char *  name,
void *  data,
rk_stub_precall_t  precall,
rk_stub_postcall_t  postcall
 

Make a simulated process that will "consume" resources during its period.

See also:
rk_resource_set_attach_process

rk_resource_set_detach_process

Parameters:
name The name of the process.
data Process specific data, if any.
precall Function to call before a data period begins, can be NUL.
postcall Function to call after a data period ends, can be NULL.
Returns:
The pid_t for the simulated process.

Definition at line 1909 of file rk_stub.c.

References MAX_PCB, require, rk_stub_data, rk_stub_postcall_t, and rk_stub_precall_t.

Referenced by BasicDelegate::BasicDelegate().

void rk_stub_next_tick void   ) 
 

Advance the simulated time.

Simulated time starts at zero and then continually advances to the next simulated event, such as a period end.

Definition at line 1878 of file rk_stub.c.

References ensure, require, rk_cpu_reserve_tick(), rk_resource_set_t, rk_stub_data, and timespec_to_microsec().

Here is the call graph for this function:

char* rk_stub_pcb_string pid_t  pid  )  [static]
 

Get the string version of a simulated pid_t value.

Parameters:
pid The simulated pid_t to stringify.
Returns:
A statically allocated string formatted with the values in the parameter.

Definition at line 428 of file rk_stub.c.

References MAX_PCB, and rk_stub_data.

Referenced by rk_proc_get_rset(), rk_resource_set_attach_process(), and rk_resource_set_detach_process().

void rk_stub_set_mode rk_stub_mode_t  mode  ) 
 

Initialize the stub code and set the desired mode.

Parameters:
mode One of the values in rk_stub_mode_t.

Definition at line 1321 of file rk_stub.c.

References lnNewList(), require, rk_stub_data, and rk_stub_mode_t.

Here is the call graph for this function:


Variable Documentation

char* rk_cpu_trace_names[RK_CPU_TRACE_MAX] [static]
 

Initial value:

 {
    "period",
    "deadline",
    "complete",
    "drop",
    "realtime",
    "success",
    "fail"
}
The string forms of the trace file enumeration.

Definition at line 72 of file rk_stub.c.

Referenced by rk_cpu_reserve_create().


Generated on Mon Dec 1 16:30:07 2003 for CPU Broker by doxygen 1.3.4