Dequeue (DEQ)


Op Code (Hex) Extender Operand 1 Operand 2 Operand 3 Operand 4-5
DEQ 1033
Message prefix Message text Queue or queue template


DEQB 1C33 Branch options Message prefix Message text Queue or queue template Branch targets


DEQI 1833 Indicator options Message prefix Message text Queue or queue template Indicator targets
Operand 1: Character variable scalar.

Operand 2: Space pointer.

Operand 3: System pointer or space pointer data object.

Operand 4-5:

Bound program access

Built-in number for DEQ is 41. DEQ ( message_prefix : address message_text : address queue : address of system pointer OR address of space pointer(16) ) : signed binary(4) /* return_code */

The return code is set as follows:

Return code

Meaning

1

Message Dequeued.

0

Message Not Dequeued.

This built-in function corresponds to the branch and indicator forms of the DEQ operation.

 
  -- OR --
 

Built-in number for DEQWAIT is 42. DEQWAIT ( message_prefix : address message_text : address queue : address of system pointer OR address of space pointer(16) )

This built-in function corresponds to the non-branch and non-indicator form of the DEQ operation.

Description

Retrieves a queue message based on the queue type (FIFO, LIFO, or keyed) specified during the queue's creation. If the queue was created with the keyed option, messages can be retrieved by any of the following relationships between an enqueued message key and a selection key specified in operand 1 of the Dequeue instruction: =, <>, >, <, <=, and >=. If the queue was created with either the LIFO or FIFO attribute, then only the next message can be retrieved from the queue.

If a message is not found that satisfies the dequeue selection criterion and the branch or indicator options are not specified, the thread waits until a message arrives to satisfy the dequeue or until the dequeue wait time-out expires. If branch or indicator options are specified, the thread is not placed in the dequeue wait state and either the control flow is altered according to the branch options, or indicator values are set based on the presence or absence of a message to be dequeued.

If operand 3 is a system pointer, the message is dequeued from the queue specified by operand 3. If operand 3 is a space pointer, the message is dequeued from the queue which is specified in the template pointed to by the space pointer. The format of this template is given later in this section. The criteria for message selection are given in the message prefix specified by operand 1. The message text is returned in the space specified by operand 2, and the message prefix is returned in the scalar specified by operand 1. If an exception is signaled, the message text and message prefix may be changed, but do not contain valid data. Improper alignment results in an exception being signaled. The format of the message prefix is as follows:

Offset
Dec Hex
Field Name
Data Type and Length
0 0
Timestamp of enqueue of message
Char(8) ++
8 8
Dequeue wait time-out value
Char(8) +



(ignored if branch options specified)


16 10
Size of message dequeued
Bin(4) ++



(The maximum allowable size of a queue message is 64 K bytes.)


20 14
Access state modification option indicator and message selection criteria
Char(1) +
20 14
Access state modification option when entering Dequeue wait
Bit 0 +



0 = Access state is not modified
1 = Access state is modified


20 14
Access state modification option when leaving Dequeue wait
Bit 1 +



0 = Access state is not modified
1 = Access state is modified


20 14
Multiprogramming level option
Bit 2 +



0 = Leave current MPL set at Dequeue wait
1 = Remain in current MPL set at Dequeue wait


20 14
Time-out option
Bit 3 +



0 = Wait for specified time, then signal time-out exception
1 = Wait indefinitely


20 14
Actual key to input key relationship
Bits 4-7 +



(for keyed queue)
0010 = Greater than
0100 = Less than
0110 = Not equal
1000 = Equal
1010 = Greater than or equal
1100 = Less than or equal


21 15
Search key (ignored for FIFO/LIFO queues but must be present for FIFO/LIFO queues with nonzero key length values)
Char(key length) +
* *
Message key
Char(key length) ++
* *
--- End ---

Note: Fields shown here with one plus sign (+) indicate input to the instruction, and fields shown here with two plus signs (++) are returned by the machine.

A nonzero dequeue wait time-out value overrides any dequeue wait time-out value specified as the current process attribute. A zero dequeue wait time-out value causes the wait time-out value to be taken from the current process attribute. If all wait time-out values are 0 (from the Dequeue instruction and the current process attribute), a dequeue time-out  (hex 3A01) exception is signaled. See Standard Time Format for additional information on the format of the dequeue wait time-out. The maximum dequeue wait time-out interval allowed is a value equal to (248 - 1) microseconds. Any value that indicates more time than the maximum wait time-out causes the maximum wait time-out to be used.

The size of message dequeued is returned in the message prefix. The size of message dequeued can be less than or equal to the maximum size of message specified when the queue was created. When dequeuing from a keyed queue, the length of the search key field and the length of the message key field (in the message key prefix specified in operand 1) are determined implicitly by the attributes of the queue being accessed. If the message text on the queue contains pointers, the message text operand must be 16-byte aligned.

The access state of the process access group is modified when a Dequeue instruction results in a wait and the following conditions exist:

The thread will remain in the current MPL set for an implementation-defined period which will not exceed 2 seconds, if the multiprogramming level option specifies remain in current MPL set at Dequeue wait. If the wait has not been satisfied at the end of this period, the thread will automatically be removed from the current MPL set. The automatic removal does not change or affect the total wait time specified for the thread by the dequeue wait time-out value.

Operand 3 can be a system pointer or a space pointer. If it is a system pointer, this pointer will be addressing the queue from which the message is to be dequeued. If it is a space pointer, this pointer will be addressing a template which will contain the system pointer to the queue as well as the dequeue template extension. The queue template is 32 bytes in length and must be aligned on a 16-byte boundary with the format as follows:


Offset
Dec Hex
Field Name
Data Type and Length
0 0
Queue
System pointer
16 10
Dequeue template extension
Char(16)
16 10
Extension options
Char(1)
16 10
Modify thread event mask option
Bit 0 +



0 = Do not modify thread event mask
1 = Modify thread event mask


16 10
Asynchronous signals processing option
Bit 1 +



0 = Do not allow asynchronous signal processing during Dequeue wait
1 = Allow asynchronous signal processing during Dequeue wait


16 10
Reserved (binary 0)
Bits 2-7
17 11
Extension area
Char(15)
17 11
New thread event mask
Bin(2) +
19 13
Previous thread event mask
Bin(2) ++
21 15
Reserved (binary 0)
Char(11)
32 20
--- End ---

Note: Fields shown here with one plus sign (+) indicate input to the instruction, and fields shown here with two plus signs (++) are returned by the machine.

The modify thread event mask option controls the state of the event mask in the thread executing this instruction. If the modify thread event mask option field specifies to modify thread event mask, the thread event mask will be changed as specified by the new thread event mask field. When the thread event mask is changed, the current thread event mask will be returned in the previous thread event mask field. The previous thread event mask is only returned when the modify thread event mask option is set to 1.

If the system security level machine attribute is hex 40 or greater and the thread is running in user state, a template value invalid  (hex 3801) exception is signalled if the modify thread event mask option is set to modify thread event mask.

If the thread event mask is in the masked state, the machine does not schedule signaled event monitors in the thread. The event monitors continue to be signaled by the machine or other threads. When the thread is modified to the unmasked state, event handlers are scheduled to handle those events that occurred while the thread was masked and those events occurring while in the unmasked state. The number of signals retained while the thread is masked is specified by the attributes of the event monitor associated with the process or thread.

The thread is automatically masked by the machine when event handlers are invoked. If the thread is unmasked in the event handler, other events can be handled if another enabled event monitor within that thread is signaled. If the thread is masked when it exits from the event handler, the machine explicitly unmasks the thread.

Valid masking values are:

0 Masked
256 Unmasked

Other values are reserved and must not be specified. If any other values are specified, a template value invalid  (hex 3801) exception is signaled.

Whether masking or unmasking the current thread, the new mask takes effect upon completion of a satisfied dequeue.

The asynchronous signals processing option controls the action to be taken if an asynchronous signal is pending or received while in a Dequeue wait. If an asynchronous signal that is not blocked or ignored is generated for the process and the asynchronous signals processing option indicates allow asynchronous signal processing during Dequeue wait, the Dequeue wait will be terminated and an asynchronous signal terminated MI wait  (hex 4C01) exception is signaled. Otherwise, when the asynchronous signals processing option indicates do not allow asynchronous signal processing during Dequeue wait, the process remains in the wait until a message arrives to satisfy the dequeue or until the dequeue wait time-out value expires.

Resultant Conditions

Authorization Required

Lock Enforcement

Exceptions

06 Addressing

08 Argument/Parameter

0A Authorization

10 Damage Encountered

1A Lock State

1C Machine-Dependent

20 Machine Support

22 Object Access

24 Pointer Specification

2E Resource Control Limit

30 Journal

32 Scalar Specification

38 Template Specification

3A Wait Time-Out

44 Protection Violation

4C Signals Management