Mesquite Software

Home
Products and FAQ
Customers
To Order
Contact Us
Site Map
Documentation
News & Events

Purchase & Download
Or, log in here to
access your account.
 
Documentation
User Guide: C : Managing Queues

9. Managing Queues

Each of the CSIM objects (facilities, storages, buffers, events and mailboxes) consists of one or more queues (for suspended processes) and some other structure (servers in a facility, a list of messages in a mailbox, etc.). In some models, it is necessary to be able to manipulate the processes in one of these queues. The queue management features are used to accomplish this.

9.1. Process Pointers and Process Structures

The structure for manipulating processes is a PROCESS_PTR:

Example: PROCESS_PTR ptr

This is the object returned when a process is requested from a CSIM object.

A PROCESS_PTR object can be used to query the state of a process and to change attributes of a process.

Prototype: long get_process_priorty(PROCESS_PTR pptr)
Example: priority = get_process_priority(pptr);
Prototype: void set_process_priorty(PROCESS_PTR pptr,
long prty)

Example: set_process_priority(pptr, 5);
Prototype: long get_process_identity(PROCESS_PTR pptr)
Example: id = get_process_identity(pptr);
Prototype: char* get_process_name(PROCESS_PTR pptr)
Example: id = get_process_identity(pptr);

A process can retrieve its own process pointer.

Prototype: PROCESS_PTR this_process(void)
Example: pptr = process_ptr();

A process can retrieve the next process from a list of processes

Prototype: PROCESS_PTR next_process(PROCESS_PTR pptr)
Example: p = next_process(pptr);

A process can have its own user-defined structure. This structure can be established by a process and be retrieved and examined by this process and other processes using a process pointer.

Prototype: void* get_this_struct(void)
Example: strct = get_this_struct();

A process can establish its own private structure.

Prototype: void set_this_struct(void *strct)
Example: set_this_struct(strct);

A process can retrieve a pointer to the private structure for another process

Prototype: void* get_process_struct(PROCESS_PTR pptr)
Example: strctr = get_process_struct(pptr);

A process can set a private structure for another process.

Prototype: void set_process_struct(PROCESS_PTR pptr,
void* strctr)

Example: set_process_struct(pptr, strctr);

9.2. Process Queues at Facilities

The queue of processes at a facility can be managed by a set of routines.
The pointer to the first process (the process at the head of the queue) can be retrieved as follows:

Prototype: PROCESS_PTR facility_first_process(FACILITY f)
Example: pptr = facility_first_process(f);

The pointer to the last process at the end of the queue (the process at the tail of the queue) can be retrieved as follows:

Prototype: PROCESS_PTR facility_last_process(FACILITY f)
Example: pptr = facility_last_process(f);

A specific process can be removed from a facility queue as follows:

Prototype: PROCESS_PTR facility_remove_process(FACILITY
f, PROCESS_PTR pptr)

Example: pptr = facility_remove_process(f, ppptr);

A process can be placed in a facility queue; the position of this process is determined by its priority relative to the other processes in the queue.

Prototype: void facility_insert_process(FACILITY f,
PROCESS_PTR pptr)

Example: facility_insert_process(f, pptr);

A process can discover if it is occupying a server at a facility:

Prototype: long in_this_facility(FACILITY f, long id)
Example: n = in_this_facility(f, identity());

This function returns true (not zero) if the process with the specified identity occupies one of the servers at the facility designated by f; this function returns false (zero) if the process does not occupy one of the servers at the facility designated by f.

9.3. Process Queues at Storages

The routines for managing processes in a storage queue are as follows:
The pointer to the first process (the process at the head of the queue) can be retrieved as follows:

Prototype: PROCESS_PTR storage_first_process(STORE s)
Example: pptr = storage _first_process(s);

The pointer to the last process at the end of the queue (the process at the tail of the queue) can be retrieved as follows:

Prototype: PROCESS_PTR storage_last_process(STORE s)
Example: pptr = storage_last_process(s);

A specific process can be removed from a storage queue as follows:

Prototype:
PROCESS_PTR storage_remove_process(STORE s,
PROCESS_PTR pptr)

Example: pptr = storage_remove_process(s, ppptr);

A process can be placed in a storage queue; the position of this process is determined by its priority relative to the other processes in the queue.

Prototype: void storage_insert_process(STORE s,
PROCESS_PTR pptr)

Example: storage_insert_process(s, pptr);

9.4. Process Queues at Buffers

A buffer has two queues of processes: the queue of processes waiting for a put operation to complete and the queue of processes waiting for a get operation to complete. These two queues are referred to as the put-queue and the get-queue respectively.

The pointer to the first process of the put-queue (the process at the head of the put-queue) can be retrieved as follows:

Prototype: PROCESS_PTR buffer_put_first_process(BUFFER b)
Example: pptr = buffer_put_first_process(b);

The pointer to the last process at the end of the put-queue (the process at the tail of the put-queue) can be retrieved as follows:

Prototype: PROCESS_PTR buffer_put_last_process(BUFFER b)
Example: pptr = buffer_put_last_process(b);

A specific process can be removed from a put-queue queue as follows:

Prototype: PROCESS_PTR buffer_put_remove_process(BUFFER
b, PROCESS_PTR pptr)

Example: pptr = buffer_put_remove_process(b, ppptr);

A process can be placed in a buffer put-queue; the position of this process is determined by its priority relative to the other processes in the queue.

Prototype: void buffer_put_insert_process(BUFFER b,
PROCESS_PTR pptr)

Example: buffer_put_insert_process(b, pptr);

The pointer to the first process of the get-queue (the process at the head of the put-queue) can be retrieved as follows:

Prototype: PROCESS_PTR buffer_get_first_process(BUFFER b)
Example: pptr = buffer_get_first_process(b);

The pointer to the last process at the end of the get-queue (the process at the tail of the get-queue) can be retrieved as follows:

Prototype: PROCESS_PTR buffer_get_last_process(BUFFER b)
Example: pptr = buffer_get_last_process(b);

A specific process can be removed from a get-queue as follows:

Prototype: PROCESS_PTR buffer_get_remove_process(BUFFER
b, PROCESS_PTR pptr)

Example: pptr = buffer_get_remove_process(b, ppptr);

A process can be placed in a buffer get-queue; the position of this process is determined by its priority relative to the other processes in the queue.

Prototype: void buffer_get_insert_process(BUFFER b,
PROCESS_PTR pptr)

Example: buffer_get_insert_process(b, pptr);

9.5. Process Queues at Events

An event has two queues of processes: the queue of processes doing a wait operation and the queue of processes doing a queue operaton. These two queues are referred to as the wait-queue and the queue-queue respectively.

The pointer to the first process of the wait-queue (the process at the head of the wait-queue) can be retrieved as follows:

Prototype: PROCESS_PTR event_first_wait_process(EVENT e)
Example: pptr = event_first_wait_process(e);

The pointer to the last process at the end of the wait-queue (the process at the tail of the wait-queue) can be retrieved as follows:

Prototype: PROCESS_PTR event_last_wait_process(EVENT e)
Example: pptr = event_last_wait_process(e);

A specific process can be removed from a wait-queue queue as follows:

Prototype: PROCESS_PTR event_remove_wait_process(EVENT e, PROCESS_PTR pptr)
Example: pptr = event_remove_wait_process(e, ppptr);

A process can be placed in an event wait-queue; the position of this process is determined by its priority relative to the other processes in the queue.

Prototype: void event_insert_wait_process(EVENT e,
PROCESS_PTR pptr)

Example: event_insert_wait_process(e, pptr);

The pointer to the first process of the queue-queue (the process at the head of the queue-queue) can be retrieved as follows:

Prototype: PROCESS_PTR event_first_queuue_process(EVENT
e)

Example: pptr = event_first_queuue_process(e);

The pointer to the last process at the end of the queue-queue (the process at the tail of the queue-queue) can be retrieved as follows:

Prototype: PROCESS_PTR event_last_queue_process(EVENT e)
Example: pptr = event_last_queue_process(e);

A specific process can be removed from a queue-queue as follows:

Prototype: PROCESS_PTR event_remove_queue_process(EVENT
e, PROCESS_PTR pptr)

Example: pptr = event_remove_queue_process(e, ppptr);

A process can be placed in a queue-queue; the position of this process is determined by its priority relative to the other processes in the queue.

Prototype: void event_insert_queue_process(EVENT e,
PROCESS_PTR pptr)

Example: event_insert_queue_process(e, pptr);

9.6. Process Queues and Message Lists at Mailboxes

A CSIM mailbox consists of queue of processes waiting to receive messages and a list of messages waiting to be received by processes.
The pointer to the first process of the process queue at a mailbox (the process at the head of the process-queue) can be retrieved as follows:

Prototype:
PROCESS_PTR mailbox_first_process(MBOX mb)
Example: pptr = mailbox_first_process(mb);

The pointer to the last process at the end of the process queue at a mailbox (the process at the tail of the process queue) can be retrieved as follows:

Prototype: PROCESS_PTR mailbox_last_process(MBOX mb)
Example: pptr = mailbox_last_process (mb);

A specific process can be removed from the process-queue at a mailbox as follows:

Prototype: PROCESS_PTR mailbox_remove_process(MBOX mb,
PROCESS_PTR pptr)

Example: pptr = mailbox_remove_process(mb, ppptr);

A process can be placed in the process queue at a mailbox; the position of this process is determined by its priority relative to the other processes in the queue.

Prototype: void mailbox_insert_process(MBOX mb,
PROCESS_PTR pptr)

Example: mailbox_insert_process(mb, pptr);

There is a pointer to a message pointer:

Example: MSG_PTR msg_ptr;

The pointer to the first message of the message list at a mailbox can be retrieved as follows:

Prototype: MSG_PTR mailbox_first_msg(MBOX mb)
Example: mptr = mailbox_first_msg(mb);

The pointer to the last message at the end of the message list at a mailbox can be retrieved as follows:

Prototype: MSG_PTR mailbox_last_msg(MBOX mb)
Example: mptr = mailbox_last_msg(mb);

A specific message can be removed from the message list at a mailbox as follows:

Prototype: MSG_PTR mailbox_remove_message(MBOX mb,
MSG_PTR mptr)

Example: mptr = mailbox_remove_message(mb, mptr);

A message can be placed in the message list at a mailbox; the position of this message is at the end of the message list.

Prototype: void mailbox_insert_message(MBOX mb,
MSG_PTR mptr)

Example: mailbox_insert_message(mb, mptr);

The next message in a list of messages can be accessed as follows:

Prototype: MSG_PTR next_msg(MSG_PTR mptr)
Example: mptr = next_msg(mptr);

The contents of a message can be examined as follows:

Prototype: long msg_content(MSG_PTR mptr)
Example: msg = msg_content(mptr);

 
Home | Products/FAQ | Customers | To Order | Contact Us | Site Map | Documentation
© copyright 2005, Mesquite Software, all rights reserved.