The full pathname to the resulting C file is what needs to be specified in the SCHD_CODE variable in local.mk before compiling the BASL scheduler to produce the pbs_sched executable.
zero or more FUNCTIONS definitions
zero or more global VARIABLE DECLARATIONS
zero or more assignment statements (to initialize global variables)
sched_main()
{
one or more VARIABLE DECLARATIONS
zero or more STATEMENTS
}
For example,
% cat sched.basl
Int sum(Int a, Int b)
{
Int s;
s = a + b;
return(s);
}
Int glob;
sched_main()
{
Int c;
a = 3;
b = 4;
c = sum(a, b);
print(c);
glob = 5;
print(glob);
}
is the function that gets called at every scheduling iteration.
ReturnType function-name ( DATATYPE1 IDENTIFIER1,
DATATYPE2 IDENTIFIER2, ... )
{
one or more VARIABLE DECLARATIONS
zero or more STATEMENTS
}
For example,
Void printStuff(Dayofweek dow, DateTime t, String str,
Size sz, CNode cn)
{
print(dow);
print(t);
print(str);
print(sz);
print(cn);
}
Valid function ReturnType are: Void, Int, Float, Dayofweek, DateTime, String, Size, Server, Que, Job, CNode, Set Server, Set Que, Set Job, Set CNode.
Valid data types ( DATATYPE1, DATATYPE2, ... ) for the parameter identifiers are: Int, Float, Dayofweek, DateTime, String, Size, Server, Que, Job, CNode, Set Server, Set Que, Set Job, Set CNode, Range Int, Range Float, Range Dayofweek, Range DateTime, Range Size, Fun Int, Fun Float, Fun Void, Fun Dayofweek, Fun DateTime, Fun String, Fun Size, Fun Server, Fun Que, Fun Job, Fun CNode, Fun Set Server, Fun Set Que, Fun Set Job, Fun Set CNode. These data types will be discussed in the next topic.
Functions are invoked by their name and their arguments as in:
printStuff( MON, (5|1|1997@14:32:00), "sched begins",
30gb, node );
basl2c will actually add a "basl_" prefix to the function name given by the scheduler writer to minimize chance of name collision, which can result when the resulting C code is linked with the PBS, BASL libraries. For example, if you look at the generated C code for printStuff, you would see,
basl_printStuff( MON, (5|1|1997@14:32:00),
"sched begins", 30gb, node );
As in C, all function calls must have been previously defined. The BASL compiler will check to make sure that arguments in the function call match up exactly (in terms of types) with the parameters in the function definition.
Two kinds of functions exist in BASL: user-defined functions and predefined functions. User-defined functions are those that the scheduler writer provided a definition for, while predefined functions are those that can immediately be called without a need for defining it. For a list of predefined functions, see section on PREDEFINED FUNCTIONS .
The syntax of a variable declaration is:
DATATYPE IDENTIFIER ;
where DATATYPE can be: Int, Float, Dayofweek, DateTime, String, Size, Server, Que, Job, CNode, Set Server, Set Que, Set Job, Set CNode, Range Int, Range Float, Range Dayofweek, Range DateTime, Range Size.
multiplier unit (bytes or words) =================== ===================== k,m,g,t,p,K,M,G,T,P b,B,w,W
where k=K=1024, m=M=1,048,576, g=G=1,073,741,824, t=T=1,099,511,627,776, p=P=1,125,899,906,842,624, b=B=1, and word size w=W is locally defined (i.e. 4 bytes in a 32-bit machine).
When operating on 2 size operands that are of different suffixes, the suffix of the "lower" of the two will be the resultant suffix. For example,
10mb + 10gb = 10250mbSample constants: -1b, 2w, 1kb, 2mw, +3gb, 4tw, 6Pb
DATA TYPE BASL-DEFINED CONSTANT
=================== =============================================
Dayofweek SUN, MON, TUE, WED, THU, FRI, SAT
Int SUCCESS, FAIL, FALSE, TRUE, SYNCRUN, ASYNCRUN,
DELETE, RERUN, HOLD, RELEASE, SIGNAL,
MODIFYATTR, MODIFYRES, SERVER_ACTIVE,
SERVER_IDLE, SERVER_SCHED, SERVER_TERM,
SERVER_TERMDELAY, QTYPE_E, QTYPE_R,
SCHED_DISABLED, SCHED_ENABLED, TRANSIT,
QUEUED, HELD, WAITING, RUNNING, EXITING,
CNODE_OFFLINE, CNODE_DOWN, CNODE_FREE,
CNODE_RESERVE, CNODE_INUSE_EXCLUSIVE,
CNODE_INUSE_SHARED, CNODE_TIMESHARED,
CNODE_CLUSTER, CNODE_UNKNOWN, OP_EQ, OP_NEQ,
OP_LE, OP_LT, OP_GE, OP_GT, OP_MAX, OP_MIN,
ASC, DESC
Server NOSERVER
Set Server EMPTYSETSERVER
CNode NOCNODE
Set CNode EMPTYSETCNODE
Que NOQUE
Set Que EMPTYSETQUE
Job NOJOB
Set Job EMPTYSETJOB
String NULLSTR
expr ;
where expr can be:
lexpr + rexpr (add)
lexpr - rexpr (subtract)
lexpr * rexpr (multiply)
lexpr / rexpr (divide)
lexpr % rexpr (modulus or remainder)
NOTE: Adding, subtracting, multiplying, dividing, and remaindering will only be allowed for proper types and if the left and right expressions are of consistent types. The table below illustrates what types are consistent among the various operators:
For +:
lexpr rexpr
============ ============
Int or Float Int or Float
Size Size
String String
For -, *, /:
lexpr rexpr
============ ============
Int or Float Int or Float
Size Size
For %:
lexpr rexpr
============ ============
Int or Float Int or Float
Here are some sample arithmetic expressions statements:
Int i1;
Int i2;
Float f1;
Float f2;
Size sz1;
Size sz2;
String str1;
String str2;
i1 + i2;
f1 - i2;
sz1 * sz2 * 2b;
sz1 / 1024b;
str1 = "basl";
str2 = " cool";
// the following is a string concatenation
// operation resulting in the string:
// "basl cool"
str1 + str2;
i1 % 10;
+expr // positive - multiplies by 1 an
// expression that is
// of Int, Float, or
// Size type
-expr // negative - multiplies by -1 an
// expression that is
// of Int, Float, or
// Size type
!expr // not - converts a non-zero expr
// value into 0, and a
// zero expr value into 1
// where expr type must be
// of type Int or Float
Some sample unary expressions:
Int i;
+3;
-(i + 4);
!i;
lexpr EQ rexpr
lexpr NEQ rexpr
lexpr LT rexpr
lexpr LE rexpr
lexpr GT rexpr
lexpr GE rexpr
lexpr AND rexpr
lexpr OR rexpr
lexpr and rexpr must have types that are mutually consistent as shown in the following table:
lterminal-expr rterminal-expr
============== ==============
Int or Float Int or Float
Dayofweek Dayofweek
DateTime DateTime
String String
Size Size
Server Server
Que Que
Job Job
CNode CNode
Set Server Set Server
Set Que Set Que
Set Job Set Job
Set CNode Set CNode
For AND, OR operators, the lexpr, rexpr consistent types are Int or Float.
Some sample logical expressions:
i1 EQ i2;
i1 NEQ f2;
dow1 LE dow2;
d1 LT d2;
str1 GT str2;
sz1 GE sz2;
IDENTIFIER++; // identifier=identifier+1
IDENTIFIER--; // identifier=identifier-1
IDENTIFIER must be of Int or Float type.
Example:
Int i;
Float f;
i++;
f--;
function-name ( arg1 ,arg2 ... , argN )
where arg1, ..., argN can be any constant or variable. You can't have another function call as an argument. Example:
Void pr(Int a) {
print(a);
}
pr(5);
There are certain predefined functions that a scheduler writer can automatically call in his/her BASL code without a need to define it. These functions are referred to as assist functions (or helper functions) and they are discussed under PREDEFINED FUNCTIONS topic.
5;
+1.2;
SUN;
MON;
TUE;
WED;
THU;
FRI;
SAT;
(4|4|1997);
(12:01:00);
(4|4|1997@12:01:00);
"wonderful";
-1b;
SYNCRUN;
ASYNCRUN;
DELETE;
RERUN;
HOLD;
RELEASE;
SIGNAL;
MODIFYATTR;
MODIFYRES;
(1, 3);
(2.3, 4.6);
(WED, FRI);
((4|4|1997), (4|10|1997));
((12:01:00), (12:30:00));
((4|4|1997@12:01:00), (4|10|1997@12:30:00));
(23gb, 50gb);
NOSERVER;
NOCNODE;
NOQUE;
NOJOB;
EMPTYSETSERVER;
EMPTYSETCNODE;
EMPTYSETQUE;
EMPTYSETJOB;
NULLSTR;
SUCCESS;
FAIL;
SERVER_ACTIVE;
SERVER_IDLE;
SERVER_SCHED;
SERVER_TERM;
SERVER_TERMDELAY;
QTYPE_E;
QTYPE_R;
SCHED_DISABLED;
SCHED_ENABLED;
FALSE;
TRUE;
TRANSIT;
QUEUED;
HELD;
WAITING;
RUNNING;
EXITING;
CNODE_OFFLINE;
CNODE_DOWN;
CNODE_FREE;
CNODE_RESERVE;
CNODE_INUSE_EXCLUSIVE;
CNODE_INUSE_SHARED;
CNODE_TIMESHARED;
CNODE_CLUSTER;
CNODE_UNKNOWN;
OP_EQ;
OP_NEQ;
OP_LE;
OP_LT;
OP_GE;
OP_GT;
OP_MAX;
OP_MIN;
Example:
Int i;
i;IDENTIFIER = expr ;
IDENTIFIER and expr must have types that are mutually consistent as illustrated in the following table:
identifier expr
=============== ===============
Int Int, Float
Float Int, Float
Dayofweek Dayofweek
DateTime DateTime
String String
Size Size
Que Que
Job Job
CNode CNode
Server Server
Dayofweek Dayofweek
DateTime DateTime
Set Server Set Server
Set Que Set Que
Set Job Set Job
Set CNode Set CNode
Range Int Range Int
Range Float Range Float
Range Dayofweek Range Dayofweek
Range DateTime Range DateTime
Range Size Range Size
if( expr ) {
zero or more (true) STATEMENTS
}
if( expr ) {
zero or more (true) STATEMENTS
} else {
zero or more (false) STATEMENTS
}
The expr 's type must be either Int or Float, and after evaluation if its value is non-zero, then the true statements are executed. On the second form, if the expr evaluates to zero, then the false statements are executed.
Some sample if statements are given below:
if (2 * x )
{
y = y + 3;
print(y);
}
if (2 * x ) {
y = y + 3;
} else {
if( 3 * x ) {
y = 4;
} else {
y = 5;
}
}
for( start; test; action ) {
zero or more STATEMENTS
}
Just like in C, for first executes start, then evaluates the test condition to see if it returns a non-zero value. If it does, the for statements are executed. After the for statements are executed, then action is evaluated, and then it checks the test condition again in the same manner as before. start and action can be a simple assignment expression or a post-operator expression. test is a logical/relational expression. Some sample for statements are given in the following:
for (i = 0; i LT 3 ; i = i + 1)
{
print(i);
}
for (i = 0; i LT 2 * x; i++)
{
if (x GT 3)
{
y = 99;
} else
{
x = 73;
}
}
foreach ( IDENTIFIER1 in IDENTIFIER2 ) {
zero or more STATEMENTS
}
where the following pairing of types for the identifiers are allowed:
IDENTIFIER1 IDENTIFIER2
=========== ===========
Server Set Server
Que Set Que
Job Set Job
CNode Set CNode
Example:
Server s;
Que q;
Job j;
CNode c;
Set Server ss;
Set Que sq;
Set Job sj;
Set CNode sc;
foreach(s in ss){
print(s);
}
foreach(q in sq){
print(q);
}
foreach(j in sj){
print(j);
}
foreach(c in sc){
print(c);
}
while ( expr ) {
zero or more STATEMENTS
}
where expr must be of Int or Float type. If expr is non-zero, then the zero or more are executed and expr is re-evaluated.
Example:
Int i;
i = 3;
while(i) {
if( i EQ 0 ) {
print("break on i = 1");
break;
}
i--;
}
switch( IDENTIFIER ) {
case constant-expr :
{
zero or more STATEMENTS
}
case constant-expr :
{
zero or more STATEMENTS
}
...
case in constant-rangeOrSet-expr :
{
zero or more STATEMENTS
}
case in IDENTIFIER-rangeOrSettype :
{
zero or more STATEMENTS
}
default :
{
zero or more STATEMENTS
}
}
where constant-expr is an expr of type Int, Float, Dayofweek, DateTime, Size, String, Server, Que, Job, or CNode. constant-rangeOrSet-expr and IDENTIFIER-rangeOrSettype can be of type Set Server, Set CNode, Set Que, Set Job, Range Int, Range Float, Range Dayofweek, Range DateTime, or Range Size.
IDENTIFIER cannot be of type Void. IDENTIFIER's type must be consistent with constant-expr's, constant-rangeOrSet-expr's, and IDENTIFIER-rangeOrSettype's type as illustrated in the following table:
IDENTIFIER constant-range-expr, IDENTIFIER-rangetype =========== ========================================= Server Set Server Que Set Que Job Set Job CNode Set CNode Int Range Int Float Range Float Dayofweek Range Dayofweek DateTime Range DateTime Size Range Size
If a case expression matches the IDENTIFIER's value, then the corresponding block of statements are executed. Unlike in C, execution does NOT fall through to the next case statement. The reason for this is that basl2c will translate this switch statement into if-elseif-else construct. The case labeled default is executed if none of the other cases are satisfied. The default is optional; if it isn't there, and if none of the cases match, no action takes place.
Example:
Dayofweek dow;
switch(dow)
{
case MON:
{
print("case MON");
}
case TUE:
{
print("case TUE");
}
case WED:
{
print("case WED");
}
case THU:
{
print("case THU");
}
case FRI:
{
print("case FRI");
}
case SAT:
{
print("case SAT");
}
case SUN:
{
print("case SUN");
}
default:
{
print("case defaulted");
}
}
Int a;
Range Int ri;
ri = (10, 12);
switch(a)
{
case in (1,5):
{
print("case 1,5");
}
case in (6,9):
{
print("case 6,9");
}
case in ri:
{
print("case ri");
}
}
print ( IDENTIFIER );
print ( constant );
Example:
DateTime dt;
CNode cn;
dt = (4|4|1997@12:13:36);
cn = AllNodesLocalHostGet();
print(dt);
print(cn);
For Set types, use foreach to go through each element and print as in:
Server s;
Set Server ss;
ss = AllServersGet();
foreach(s in ss) {
print(s);
}
continue ;
The continue statement must have been invoked within a for, foreach, and while loop. It causes the next iteration of the enclosing loop to begin.
break ;
The break statement must have been invoked within a for, foreach, and while loop. It provides an early exit from the enclosing loop.
return(IDENTIFIER) ;
return(constant) ;
return() ;
The return statement provides the value (if any) to be returned by a function. The type returned by IDENTIFIER and constant must match the calling function's return type. constant types allowed are anything except Set and Range types. The last format, return() is usually called within a function that doesn't return any value ( like sched_main() ).
exit(constant);
where constant is of type Int. Calling this will terminate the scheduler.
// this line is ignored
Int i; // string following the slashes is ignored Operator Associativity
======================================= =============
! ++ -- + (unary plus) - (unary minus) right
* / % left
+ - left
LT LE GT GE left
EQ NEQ left
AND left
OR left
= right
Example:
Int cpuAvail; // return the # of cpus currently available in // the server cpuAvail = ServerIntResAvailGet(server, "ncpus");
Example:
Size memAvail; // return the amount of available memory in // the server memAvail = ServerSizeResAvailGet(server, "mem");
Example:
String type; // return the architecture (or os type) of // the server type = ServerStringResAvailGet(server, "arch");
Example:
Int cpuAssn; // return the # of cpus currently assigned in // the server cpuAssn = ServerIntResAssignGet(server, "ncpus");
Example:
Size sdsAssn; // return the amount of sds space currently assigned // in the server sdsAssn = ServerSizeResAssignGet(server, "sds");
Example:
Int cputReq; // returns the cput requirement of the job cputReq = JobIntResReqGet(job, "cput");
Example:
Size memReq; // returns the memory requirement of the job memReq = JobSizeResReqGet(job, "mem");
Example:
String nodes; // returns the nodes requirement property of // the job nodes = JobStringResReqGet(job, "nodes");
Example:
Int walltUse; // returns the amount of walltime used by // the job walltUse = JobIntResUseGet(job, "walltime");
Example:
Size srfsUse; // returns the amount of srfs_fast used by // the job srfsUse = JobSizeResUseGet(job, "srfs_fast");
// get total physical memory CNodeMemTotalGet(node, "real") // get total virtual memory CNodeMemTotalGet(node, "virtual")
// get available physical memory CNodeMemAvailGet(node, "real") // get available virtual memory CNodeMemAvailGet(node, "virtual")
CNodeNetworkBwGet( node, "hippi" ); CNodeNetworkBwGet( node, "fddi" );
CNodeDiskSpaceTotalGet( node, "/scratch2" );
CNodeDiskSpaceAvailGet( node, "/scratch1" );
CNodeDiskSpaceReservedGet( node, "/scratch1" );
CNodeDiskInBwGet( node, "/fast" );
CNodeDiskOutBwGet( node, "/big" );
CNodeSwapSpaceTotalGet( node, "primary" );
CNodeSwapSpaceAvailGet( node, "secondary" );
CNodeSwapInBwGet(node, "secondary");
CNodeSwapOutBwGet(node, "primary");
CNodeTapeSpaceTotalGet(node, "4mm");
CNodeTapeSpaceAvailGet(node, "8mm");
CNodeTapeInBwGet( node, "4mm" );
CNodeTapeOutBwGet( node, "8mm" );
CNodeSrfsSpaceTotalGet(node, "/fast");
CNodeSrfsSpaceAvailGet( node, "/big" );
CNodeSrfsSpaceReservedGet( node, "/fast" );
CNodeSrfsInBwGet( node, "/fast" );
CNodeSrfsOutBwGet( node, "/big" );
Action Description
=============== ==========================
SYNCRUN runs the job synchronously,
meaning the call to
JobAction() will only
return when the job has
started running or when
an error has been
encountered.
Param value:
name of host(s) to run
job under.
ASYNCRUN runs the job asynchronously,
meaning the call to
JobAction() will return
immediately as soon as
the run request is
validated by the PBS server,
and not necessarily when
the job has started
execution.
Param value:
name of host(s) to run
job under.
DELETE deletes the job.
Param value:
"deldelay=<# of secs>"
- delay # of seconds
between the sending
of SIGTERM and SIGKILL
to the job before
getting deleted.
RERUN reruns the running job,
which involves terminating
the session leader of the
job and returning the job
to the queued state.
HOLD places one or more holds
on the job.
Param value:
"u", "o", "s", "uo", "os",
"uos"
- type of holds to place
on job: u(ser), o(ther),
s(ystem).
RELEASE removes or releases
holds placed on jobs.
Param value:
"u", "o", "s", "uo", "os",
"uos"
- type of holds to remove
from job: u(ser), o(ther),
s(ystem).
SIGNAL sends a signal to the
executing job.
Param value:
"HUP", "SIGHUP",...
MODIFYATTR modifies the specified
attribute of the job to
the given value, when
the attrib_name is
!= "Resource_List" or
"resources_used".
Param value:
"attrib_name=value"
MODIFYRES modifies the job's
Resource_List
attribute given the
res_name and the
res_value:
Resource_List.res_name=
res_value
Param value:
"res_name=res_val"
param value depends on the action. Specify NULLSTR if no
value for this parameter is desired.
Return value: SUCCESS or FAIL.
NOTE: Any unrecognized action is ignored.
Example:
// run Job j synchronously JobAction(j, SYNCRUN, NULLSTR); // run Job j asynchronously on host "db" JobAction(j, ASYNCRUN, "db"); // delete Job j JobAction(j, DELETE, NULLSTR); // delete Job j with a delay of 5 secs // between the sending of SIGTERM and // SIGKILL JobAction(j, DELETE, "deldelay=5"); // rerun Job j JobAction(j, RERUN, NULLSTR); // place a u(ser) hold on Job j JobAction(j, HOLD, "u"); // place an o(ther) hold on Job j JobAction(j, HOLD, "o"); // place a s(ystem) hold on Job j JobAction(j, HOLD, "s"); // place a default hold (u) on Job j JobAction(j, HOLD, NULLSTR); // release u(ser) hold from Job j JobAction(j, RELEASE, "u"); // release o(ther) hold from Job j JobAction(j, RELEASE, "o"); // release s(ystem) hold from Job j JobAction(j, RELEASE, "s"); // release default hold (u) from Job j JobAction(j, RELEASE, NULLSTR); // send SIGHUP signal to Job j JobAction(j, SIGNAL, "SIGHUP"); // update the comment attribute of Job // j to "a message". // The param format is: attribute_name=new_value // Consult PBS documentation for a list of job // attribute names that can be specified. JobAction(j, MODIFYATTR, "comment=a message"); // update the Resource_List.cput attribute of Job // j to 3600 seconds. // The param format is: resource_name=new_value // See pbs_resources* man page for a list of // resource_names that can be specified. JobAction(j, MODIFYRES, "cput=3600");
where cpr is one of: OP_EQ, OP_NEQ, OP_LE, OP_LT, OP_GE, OP_GT. func is a function whose ONLY argument is of Job type. Job is the return type.
Description: Applies func to every job in que , and return the first job that satisfies the logical comparison: func(job) cpr value
Example:
Size JobVirtualMemAvailGet(Job job)
{
Size sz;
sz = JobSizeResReqGet(job, "mem");
return(sz);
}
Int JobWallTimeReqGet(Job job)
{
Int wallt;
wallt = JobIntResReqGet(job, "walltime");
return(wallt);
}
Int JobCpuTimeUsedGet(Job job)
{
Int cput;
cput = JobIntResUseGet(job, "cput");
return(cput);
}
Que findQueByName(Set Que queues, String qname)
{
Que q;
foreach(q in queues) {
if( QueNameGet(q) EQ qname ) {
return(q);
}
}
return(NOQUE);
}
sched_main()
{
Server s;
Que que;
Set Que sq;
// get local server
s = AllServersLocalHostGet();
// get the queues of the Server s
sq = ServerQueuesGet(s);
// get the queue named "fast" from the
// local server
que = findQueByName( sq, "fast" );
// Find the 1st job whose walltime requirement
// is == 300s:
QueJobFind(que, JobWallTimeReqGet, OP_EQ, 300);
// Find the 1st job whose email address to
// notify about job activity != "bayucan":
QueJobFind(que, JobEmailAddrGet, OP_NEQ,
"bayucan");
// Find the 1st job that was created after
// or on 3/3/1997:
QueJobFind(que, JobDateTimeCreatedGet, OP_GE,
(3|3|1997));
// Find the 1st job that was created after
// 3:3:44:
QueJobFind(que, JobDateTimeCreatedGet, OP_GT,
(3:3:44));
// Find the 1st job that was created after
// 3:3:44 on 3/3/1997:
QueJobFind(que, JobDateTimeCreatedGet, OP_GT,
(3|3|1997@3:3:44));
// Find the 1st job whose cpu time used < 1600s:
QueJobFind(que, JobCpuTimeUsedGet, OP_LT, 1600);
// Find the 1st job whose virtual memory
// requirement <= 300mb:
QueJobFind(que, JobVirtualMemAvailGet, OP_LE,
300mb);
}
where cpr can be one of the following: OP_MAX, OP_MIN, func is a function whose only argument is of Job type.
Description: Returns the Job with the max or min value found for func(job) as it is applied to every job in que.
Example:
Int JobCpuTimeReqGet(Job job)
{
Int cput;
cput = JobIntResReqGet(job, "cput");
return(cput);
}
sched_main()
{
Que que;
Job job;
// Find the Job with the highest cpu time
// requirement:
job = QueJobFind(que, JobCpuTimeReqGet, OP_MAX);
// Find the Job with the minimum cpu time
// requirement:
job = QueJobFind(que, JobCpuTimeReqGet, OP_MIN);
}
where cpr can be one of the following: OP_EQ, OP_NEQ, OP_LE, OP_LT, OP_GE, OP_GT, func is a function whose only argument is of Job type.
Description: Applies func to every job in que , and returns a new que containing all jobs that satisfies the comparison condition: func(job) cpr value
Example:
Int JobWallTimeReqGet(Job job)
{
Int wallt;
wallt = JobIntResReqGet(job, "walltime");
return(wallt);
}
sched_main()
{
Que que;
Que newq;
// Returns a new que containing all jobs in "que"
// with a walltime requirement == 300s:
newq = QueFilter(que, JobWallTimeReqGet, OP_EQ, 300);
// Returns a new que containing all jobs in "que"
// with an email address != "bayucan":
newq = QueFilter(que, JobEmailAddrGet, OP_NEQ, "bayucan");
// Returns a new que containing all jobs in "que"
// created after or on 3/3/1997:
newq = QueFilter(que, JobDateTimeCreatedGet, OP_GE,
(3|3|1997));
// Returns a new que containing all jobs in "que"
// created after 3:3:44:
newq = QueFilter(que, JobDateTimeCreatedGet, OP_GT,
(3:3:44));
// Returns a new que containing all jobs in "que"
// created after 3:3:44 on 3/3/1997:
newq = QueFilter(que, JobDateTimeCreatedGet, OP_GT,
(3|3|1997@3:3:44));
// NOTE: The original "que" is not modified
// whatsoever.
}
where s the set of jobs to sort. key is the sorting key which is a function whose only argument is of Job type, order is the sorting order: ASC, DESC.
Description: sorts the elements of s , in either ASCending or DESCending order of values that were returned by the key function, as applied to every member of the set of jobs. The s object is modified with this call. This returns SUCCESS or FAIL depending on outcome of the sort.
Examples:
Size JobMemReqGet(Job job)
{
Size mem;
mem = JobSizeResReqGet(job, "mem");
return(mem);
}
sched_main()
{
Server master;
Set Job jobs;
Int order;
// get local server
master = AllServersLocalHostGet();
jobs = ServerJobsGet(master);
Sort(jobs, JobPriorityGet, ASC);
Sort(jobs, JobIdGet, DESC);
order = ASC;
Sort(jobs, JobDateTimeCreatedGet, order);
order = DESC;
Sort(jobs, JobMemReqGet, order);
}
where s the set of queues to sort. key is the sorting key which is a function whose only argument is of Que type, order is the sorting order: ASC, DESC.
Description: sorts the elements of s , in either ASCending or DESCending order of values that were returned by the key function, as applied to every member of the set of queues. The s object is modified with this call. This returns SUCCESS or FAIL depending on outcome of the sort.
Examples:
Size QueMemAvailGet(Que que)
{
Size mem;
mem = QueSizeResAvailGet(que, "mem");
return(mem);
}
sched_main()
{
Server master;
Set Que ques;
Int order;
// get local server
master = AllServersLocalHostGet();
ques = ServerQueuesGet(master);
Sort(ques, QuePriorityGet, ASC);
Sort(ques, QueNameGet, ASC);
order = DESC;
Sort(ques, QueMemAvailGet, order);
}
where s the set of servers to sort. key is the sorting key which is a function whose only argument is of Server type, order is the sorting order: ASC, DESC.
Description: sorts the elements of s , in either ASCending or DESCending order of values that were returned by the key function, as applied to every member of the set of servers. The s object is modified with this call. This returns SUCCESS or FAIL depending on outcome of the sort.
Examples:
Size ServerMemAvailGet(Server serv)
{
Size mem;
mem = ServerSizeResAvailGet(serv, "mem");
return(mem);
}
sched_main()
{
Set Server sserver;
Int order;
Int ret;
sserver = AllServersGet();
ret = Sort(sserver, ServerMaxRunJobsGet, ASC);
Sort(sserver, ServerInetAddrGet, ASC);
order = DESC;
Sort(sserver, ServerMemAvailGet, order);
}
where s the set of nodes to sort. key is the sorting key which is a function whose only argument is of CNode type, order is the sorting order: ASC, DESC.
Description: sorts the elements of s , in either ASCending or DESCending order of values that were returned by the key function, as applied to every member of the set of nodes. The s object is modified with this call. This returns SUCCESS or FAIL depending on outcome of the sort.
Examples:
Size CNodeMyMemAvailGet(CNode cn)
{
Size mem;
mem = CNodeMemAvailGet(cn, "virtual");
return(mem);
}
sched_main()
{
Set CNode scnode;
Int order;
scnode = AllNodesGet();
Sort(scnode, CNodeIdletimeGet, ASC);
Sort(scnode, CNodeNameGet, ASC);
order = DESC;
Sort(scnode, CNodeMyMemAvailGet, order);
}For all architectures:
CNode..Get() actual call host resource ======================== ============= CNodeOsGet(node) arch CNodeLoadAveGet(node) loadave CNodeIdletimeGet(node) idletime