[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 2

rs_op Subroutine

Purpose

Performs a set of operations on one or two resource sets.

Library

Standard C library (libc.a)

Syntax

#include <sys/rset.h>
int rs_op (command, rset1, rset2, flags, id)
unsigned int command;
rsethandle_t rset1, rset2;
unsigned int flags;
unsigned int id;

Description

The rs_op subroutine performs the operation specified by the command parameter on resource set rset1 or both resource sets rset1 and rset2.

Parameters

command Specifies the operation to apply to the resource sets identified by rset1 and rset2. One of the following values, defined in rset.h, can be used:
  • RS_UNION: The resources contained in either rset1 or rset2 are stored in rset2.
  • RS_INTERSECTION: The resources that are contained in both rset1 and rset2 are stored in rset2.
  • RS_EXCLUSION: The resources in rset1 that are also in rset2 are removed from rset2. On completion, rset2 contains all the resources that were contained in rset2 but were not contained in rset1.
  • RS_COPY: All resources in rset1 whose type is flags are stored in rset2. If rset1 contains no resources of this type, rset2 will be empty. The previous content of rset2 is lost, while the content of rset1 is unchanged.
  • RS_FIRST: The first resource whose type is flags is retrieved from rset1 and stored in rset2. If rset1 contains no resources of this type, rset2 will be empty.
  • RS_NEXT: The resource from rset1 whose type is flags and that follows the resource contained in rset2 is retrieved and stored in rset2. If no resource of the appropriate type follows the resource specified in rset2, rset2 will be empty.
  • RS_NEXT_WRAP: The resource from rset1 whose type is flags and that follows the resource contained in rset2 is retrieved and stored in rset2. If no resource of the appropriate type follows the resource specified in rset2, rset2 will contain the first resource of this type in rset1.
  • RS_ISEMPTY: Test if resource set rset1 is empty.
  • RS_ISEQUAL: Test if resource sets rset1 and rset2 are equal.
  • RS_ISCONTAINED: Test if all resources in resource set rset1 are also contained in resource set rset2.
  • RS_TESTRESOURCE: Test if the resource whose type is flags and index is id is contained in resource set rset1.
  • RS_ADDRESOURCE: Add the resource whose type is flags and index is id to resource set rset1.
  • RS_DELRESOURCE: Delete the resource whose type is flags and index is id from resource set rset1.
rset1 Specifies the resource set handle for the first of the resource sets involved in the command operation.
rset2 Specifies the resource set handle for the second of the resource sets involved in the command operation. This resource set is also used, on return, to store the result of the operation, and its previous content is lost. The rset2 parameter is ignored on the RS_ISEMPTY, RS_TESTRESOURCE, RS_ADDRESOURCE, and RS_DELRESOURCE commands.
flags When combined with the RS_COPY command, the flags parameter specifies the type of the resources that will be copied from rset1 to rset2. When combined with an RS_FIRST or an RS_NEXT command, the flags parameter specifies the type of the resource that will be retrieved from rset1. This parameter is constructed by logically ORing one or more of the following values, defined in rset.h:
  • R_PROCS: processors
  • R_MEMPS: memory pools
  • R_ALL_RESOURCES: processors and memory pools

If none of the above are specified for flags, R_ALL_RESOURCES is assumed.

id On the RS_TESTRESOURCE, RS_ADDRESOURCE, and RS_DELRESOURCE commands, the id parameter specifies the index of the resource to be tested, added, or deleted. This parameter is ignored on the other commands.

Return Values

If successful, the commands RS_ISEMPTY, RS_ISEQUAL, RS_ISCONTAINED, and RS_TESTRESOURCE return 0 if the tested condition is not met and 1 if the tested condition is met. All other commands return 0 if successful. If unsuccessful, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The rs_op subroutine is unsuccessful if one or more of the following are true:

EINVAL If one of the following is true:
  • rset1 identifies an invalid resource set.
  • rset2 identifies an invalid resource set.
  • command identifies an invalid operation.
  • command is RS_NEXT or RS_NEXT_WRAP*, and rset2 does not contain a single resource.
  • command is RS_NEXT or RS_NEXT_WRAP*, and the single resource contained in rset2 is not also contained in rset1.
  • flags identifies an invalid resource type.
  • id specifies a resource index that is too large.
EFAULT Invalid address.

Related Information

The rs_alloc Subroutine.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]