Scheduling


 #include <cio/sched.h> 

Data Structures

struct  cio_context
 Buffer for saving stack and register state. More...

Defines

#define CIO_INPUT
 File descriptor may be read from.
#define CIO_OUTPUT
 File descriptor may be written to.
#define CIO_ERROR
 Error while waiting for I/O.
#define CIO_HANGUP
 Hang-up while waiting for I/O.
#define CIO_CLOSE
 File descriptor was closed while waiting for I/O.

Functions

int cio_wait (int fd, int events)
int cio_yield (struct cio_context *storage)
void cio_run (struct cio_context *target, int value)

Function Documentation

void cio_run ( struct cio_context target,
int  value 
)

Jump to another routine immediately.

Parameters:
target execution context to be resumed
value to be returned by the cio_yield() call in the target routine (must be greater than zero)
int cio_wait ( int  fd,
int  events 
)

Wait for I/O events on a file descriptor.

Parameters:
fd a file descriptor which supports polling
events bitwise OR of CIO_INPUT and/or CIO_OUTPUT
Returns:
the I/O events (bitwise OR of CIO_INPUT, CIO_OUTPUT, CIO_ERROR, CIO_HANGUP and/or CIO_CLOSE) which caused the execution to resume
Return values:
-1 on error with errno set
int cio_yield ( struct cio_context storage  ) 

Save current execution context and schedule the next routine. This function returns after an I/O event subscribed to with cio_register() occurs or another routine calls cio_run() with the execution context stored here.

Parameters:
storage for saving the stack and register state until execution is resumed
Returns:
the I/O events (bitwise OR of CIO_INPUT, CIO_OUTPUT, CIO_ERROR and/or CIO_HANGUP) which caused the execution to resume if cio_register() was used; or
the value passed to cio_run() if it was used
Return values:
-1 on interrupt with errno set