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

9. Managing Queues

Each of the CSIM objects (facilities, storages, etc.) 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 class for manipulating processes is process: A typedef defines a pointer to an instance of a process class.

Example: process *pPtr;
Example: process_t pPtr;

This is the object returned when a process is requested from a CSIM object.
A process pointer can be used to query the state of a process and to change attributes of a process.

Prototype: long process::priority(void)
Example: priority = pptr->priority();
Prototype: void process::set_priorty(long prty)
Example: pptr->set_priority(5);
Prototype: long process::identity(void)
Example: id = pptr->identity();
Prototype: char* process::name(void)
Example: nm = pptr->name();

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

Prototype: process_t process::next(void)
Example: p = pptr->next();

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: strctr = et_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* process::get_struct(void)
Example: strctr = pptr->get_struct();

A process can set a private structure for another process.

Prototype: void process::set_struct(void* strctr)
Example: strctr = pptr->set_struct(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_t facility::first_process(void)
Example: pptr = f->first_process();

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_t facility:last_process(void)
Example: pptr = f->last_process();

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

Prototype: process_t facility:remove_process(process_t
pptr)

Example: pptr = f->remove_process(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(process_t pptr)
Example: f->insert_process(pptr);

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_t storage:first_process(void)
Example: pptr = s->first_process();

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_t storage:last_process(void)
Example: pptr = s->last_process();

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

Prototype: process_t storage:remove_process(process_t
pptr)

Example: pptr = s->remove_process(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(process_t pptr)
Example: s->insert_process(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_t buffer:put_first_process(void)
Example: pptr = b->put_first_process();

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_t buffer:put_last_process(void)
Example: pptr = b->put_last_process();

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

Prototype: process_t buffer:put_remove_process(process_t
pptr)

Example: pptr = b->put_remove_process(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(process_t 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_t buffer:get_first_process(void)
Example: pptr = b->get_first_process();

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_t buffer:get_last_process(void)
Example: pptr = b->get_last_process();

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

Prototype: procees_t buffer:get_remove_process(process_t
pptr)

Example: pptr = b->get_remove_process(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(process_t pptr)
Example: b->get_insert_process(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_t event:first_wait_process(void)
Example: pptr = e->first_wait_process();

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_t event:last_wait_process(void)
Example: pptr = e->last_wait_process();

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

Prototype: process_t event:remove_wait_process(process_t
pptr)

Example: pptr = e->remove_wait_process(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 e->insert_wait_process(process_t pptr)
Example: e->insert_wait_process(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_t event:first_queuue_process()
Example: pptr = e->first_queuue_process();

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_t event_last_queue_process(void)
Example: pptr = e->last_queue_process();

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

Prototype: process_t event:remove_queue_process(process_t
pptr)

Example: pptr = event:remove_queue_process(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(pptr)
Example: e->insert_queue_process(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_t mailbox:first_process(void)
Example: pptr = mb->first_process();

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_t mailbox:last_process(void)
Example: pptr = mb->last_process();

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

Prototype: process_t mailbox:remove_process(pptr)
Example: pptr = mb->remove_process(pptr);

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(process_t pptr)
Example: mb->insert_process(pptr);

There is a pointer to a message pointer:

Example: message *msg_ptr;
Example: message_t msg_ptr;

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

Prototype: message_t mailbox::first_msg()
Example: msg_ptr = mb->first_msg();

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

Prototype: message_t mailbox::last_msg()
Example: msg_ptr = mb->last_msg();

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

Prototype: message_t mailbox:remove_message(message_t
mptr)

Example: msg_ptr = mb->remove_message(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(message_t mptr)
Example: mb->insert_message(mptr);

An instance of a message class is a message object. A pointer to a message object is defined as follows:

Example: message *mptr;
Example: message_t mptr;

The content (the integer payload for the message) can be retrieved from a message object as follows:

Prototype: long message::content(void);
Example: msg = msg_ptr->content();

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

Prototype: message_t message:: next_msg(void)
Example: msg_ptr = msg_ptr->next_msg();

Next Section

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