KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
resource.h File Reference

Basic definitions for resource operations. More...

#include <limits.h>
#include <sys/time.h>
#include <sys/types.h>

Go to the source code of this file.

Data Structures

struct  rlimit
 
struct  rusage
 

Macros

#define RLIM_INFINITY   UINT_MAX
 
#define RLIM_SAVED_MAX   RLIM_INFINITY
 
#define RLIM_SAVED_CUR   RLIM_INFINITY
 

Typedefs

typedef unsigned int rlim_t
 

Enumerations

enum  { PRIO_PROCESS , PRIO_PGRP , PRIO_USER }
 
enum  {
  RLIMIT_CORE , RLIMIT_CPU , RLIMIT_DATA , RLIMIT_FSIZE ,
  RLIMIT_NOFILE , RLIMIT_STACK , RLIMIT_AS
}
 
enum  { RUSAGE_SELF , RUSAGE_CHILDREN }
 

Functions

int getpriority (int which, id_t who)
 Obtain the nice value of a process, process group, or user.
 
int setpriority (int which, id_t who, int value)
 Sets the nice value of a process, process group, or user.
 
int getrlimit (int resource, struct rlimit *rlp)
 Gets the maximum resource consumption limits.
 
int setrlimit (int resource, const struct rlimit *rlp)
 Sets the maximum resource consumption limits.
 
int getrusage (int who, struct rusage *r_usage)
 Get information about cpu utilization.
 

Detailed Description

Basic definitions for resource operations.

This file provides a basic implementation of the POSIX/XSI standard for resource operations. These are meant to be per-process, so are basically stubs for the purposes of KOS which is single-process.

Macro Definition Documentation

◆ RLIM_INFINITY

#define RLIM_INFINITY   UINT_MAX

◆ RLIM_SAVED_CUR

#define RLIM_SAVED_CUR   RLIM_INFINITY

◆ RLIM_SAVED_MAX

#define RLIM_SAVED_MAX   RLIM_INFINITY

Typedef Documentation

◆ rlim_t

typedef unsigned int rlim_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PRIO_PROCESS 
PRIO_PGRP 
PRIO_USER 

◆ anonymous enum

anonymous enum
Enumerator
RLIMIT_CORE 
RLIMIT_CPU 
RLIMIT_DATA 
RLIMIT_FSIZE 
RLIMIT_NOFILE 
RLIMIT_STACK 
RLIMIT_AS 

◆ anonymous enum

anonymous enum
Enumerator
RUSAGE_SELF 
RUSAGE_CHILDREN 

Function Documentation

◆ getpriority()

int getpriority ( int which,
id_t who )

Obtain the nice value of a process, process group, or user.

In KOS we don't have a concept currently of any of these things, so this is effectively a stub that will only return a value if requested for the default/current id.

Parameters
whichWhich type of ID to get the nice value of.
whoOnly 0 is currently valid.
Return values
0On success.
-1On error, errno will be set as appropriate.
Error Conditions:
EINVAL - which was an invalid value. EINVAL - who was a value other than 0.

Referenced by main().

◆ getrlimit()

int getrlimit ( int resource,
struct rlimit * rlp )

Gets the maximum resource consumption limits.

Everything will return RLIM_INFINITY as we impose no such limits.

Parameters
resourceThe type of resource to get the rlimit for.
rlpWhere to place the rlimit data.
Return values
0On success.
-1On error, errno will be set as appropriate.
Error Conditions:
EINVAL - resource was an invalid value.

◆ getrusage()

int getrusage ( int who,
struct rusage * r_usage )

Get information about cpu utilization.

For the purposes of this function, KOS is treated as having a single process that all threads are running under. As such RUSAGE_SELF will return user time that is the sum of all living threads and system time that is all the rest (IRQs + dead threads). RUSAGE_CHILDREN will return zero.

Parameters
whoRUSAGE_SELF or RUSAGE_CHILDREN.
r_usagerusage data to be filled.
Return values
0On success.
-1On error, errno will be set as appropriate.
Error Conditions:
EINVAL - who was an invalid value.

Referenced by main().

◆ setpriority()

int setpriority ( int which,
id_t who,
int value )

Sets the nice value of a process, process group, or user.

In KOS we don't have a concept currently of any of these things, so this is effectively a stub that will only set a value if requested for the default/current id. This also currently has no impact aside from changing the return of getpriority.

Parameters
whichWhich type of ID to set the nice value of.
whoOnly 0 is currently valid.
valuenice value to set.
Return values
0On success.
-1On error, errno will be set as appropriate.
Error Conditions:
EINVAL - which was an invalid value. EINVAL - who was a value other than 0.

Referenced by main().

◆ setrlimit()

int setrlimit ( int resource,
const struct rlimit * rlp )

Sets the maximum resource consumption limits.

Just a stub. Errors on bad input, otherwise always succeeds.

Parameters
resourceThe type of resource to set the rlimit for.
rlpIgnored.
Return values
0On success.
-1On error, errno will be set as appropriate.
Error Conditions:
EINVAL - resource was an invalid value.