TABLE OF CONTENTS
- /Syncpipe
- Syncpipe/Syncpipe_Header
- Syncpipe/Os_syncpipe_create
- Syncpipe/Os_syncpipe_kill
- Syncpipe/Os_syncpipe_receive
- Syncpipe/Os_syncpipe_send
/Syncpipe [ Modules ]
DESCRIPTION
A synced Pipe is an object dedicated to Task communication. A Task can write and read an undefined number of bytes into the Pipe. Unlike the normal Pipe object, the sending and the receiving tasks are synchronized together with the queue mode action, then the data is copied directly from one Task to another.
SEE ALSO
/Messagequeue, /Mutex, /Pipe, /Semaphore, /Signal
Syncpipe/Syncpipe_Header [ Object Headers ]
[ Top ] [ Syncpipe ] [ Object Headers ]
DESCRIPTION
Header structure of the Syncpipe object
DECLARATION
Const Os_syncpipe_hdr_senddata_ptr = 0 Const Os_syncpipe_hdr_recvdata_ptr = 2 Const Os_syncpipe_hdr_msgsize_ptr = 4 Const Os_syncpipe_hdr_sendtask_ptr = 6 Const Os_syncpipe_hdr_recvtask_ptr = 8 Const Os_syncpipe_hdr_size = 10
Syncpipe/Os_syncpipe_create [ Functions ]
[ Top ] [ Syncpipe ] [ Functions ]
DESCRIPTION
Creates a new Syncpipe object
DECLARATION
Function Os_syncpipe_create() As Word
SOURCE
Local Syncpipe As Word Syncpipe = Malloc(os_syncpipe_hdr_size) If Syncpipe = 0 Then Os_syncpipe_create = 0 Exit Function End If Os_mem_clear Syncpipe , Os_syncpipe_hdr_size Os_syncpipe_create = Syncpipe End Function
Syncpipe/Os_syncpipe_kill [ Functions ]
[ Top ] [ Syncpipe ] [ Functions ]
DESCRIPTION
Kills a Syncpipe object
DECLARATION
Sub Os_syncpipe_kill(byref Syncpipe As Word)
SOURCE
Free Syncpipe End Sub
Syncpipe/Os_syncpipe_receive [ Functions ]
[ Top ] [ Syncpipe ] [ Functions ]
DESCRIPTION
Receives an undefined count of bytes from the Pipe, synchronizes the receiving Task with the sender according to the queue mode action.
DECLARATION
Function Os_syncpipe_receive(byref Syncpipe As Word , Byref Recvpointer As Word , Byref Size As Word , Byval Queuemode As Word) As Byte
SEE ALSO
Syncpipe/Os_syncpipe_send
SOURCE
Local Sendpointer As Word Os_enter_critical Sendpointer = Getword(Syncpipe , Os_syncpipe_hdr_senddata_ptr) If Sendpointer = 0 Then ' no sender ' Select Case Queuemode Case Os_queuemode_noblock: ' return error ' Os_exit_critical Os_syncpipe_receive = False Exit Function Case Os_queuemode_block: ' suspend and wait to send a message ' Os_task_suspendmode Os_task_active , Os_task_suspend_nowakeup , 0 Case Else ' suspend and wait to send a message or timeout ' Os_task_suspendmode Os_task_active , Os_task_suspend_timersingleshot , Queuemode End Select ' suspend ' Setword Syncpipe , Os_syncpipe_hdr_recvtask_ptr , Os_task_active Setword Syncpipe , Os_syncpipe_hdr_recvdata_ptr , Recvpointer Os_exit_critical Os_task_suspend Os_task_active Os_enter_critical Sendpointer = Getword(Syncpipe , Os_syncpipe_hdr_senddata_ptr) If Sendpointer = 0 Then ' timeout error ' Os_exit_critical Os_syncpipe_receive = False Exit Function End If End If If Sendpointer = 1 Then Setword Syncpipe , Os_syncpipe_hdr_senddata_ptr , 0 Setword Syncpipe , Os_syncpipe_hdr_recvdata_ptr , 0 Os_exit_critical Else Os_mem_copy Sendpointer , Recvpointer , Size Sendpointer = Getword(Syncpipe , Os_syncpipe_hdr_sendtask_ptr) Setword Syncpipe , Os_syncpipe_hdr_senddata_ptr , 0 Setword Syncpipe , Os_syncpipe_hdr_recvdata_ptr , 1 Os_exit_critical Os_event_task = Sendpointer Os_task_event End If Os_syncpipe_receive = True End Function
Syncpipe/Os_syncpipe_send [ Functions ]
[ Top ] [ Syncpipe ] [ Functions ]
DESCRIPTION
Sends an undefined count of bytes into the Pipe, synchronizes the sending Task with the receiver according to the queue mode action.
DECLARATION
Function Os_syncpipe_send(byref Syncpipe As Word , Byref Sendpointer As Word , Byval Size As Word , Byval Queuemode As Word) As Byte
SEE ALSO
Syncpipe/Os_syncpipe_receive
SOURCE
Local Recvpointer As Word Os_enter_critical Recvpointer = Getword(Syncpipe , Os_syncpipe_hdr_recvdata_ptr) If Recvpointer = 0 Then ' no receiver ' Select Case Queuemode Case Os_queuemode_noblock: ' return error ' Os_exit_critical Os_syncpipe_send = False Exit Function Case Os_queuemode_block: ' suspend and wait to send a message ' Os_task_suspendmode Os_task_active , Os_task_suspend_nowakeup , 0 Case Else ' suspend and wait to send a message or timeout ' Os_task_suspendmode Os_task_active , Os_task_suspend_timersingleshot , Queuemode End Select ' suspend ' Setword Syncpipe , Os_syncpipe_hdr_sendtask_ptr , Os_task_active Setword Syncpipe , Os_syncpipe_hdr_senddata_ptr , Sendpointer Setword Syncpipe , Os_syncpipe_hdr_msgsize_ptr , Size Os_exit_critical Os_task_suspend Os_task_active Os_enter_critical Recvpointer = Getword(Syncpipe , Os_syncpipe_hdr_recvdata_ptr) If Recvpointer = 0 Then ' timeout error ' Os_exit_critical Os_syncpipe_send = False Exit Function End If End If If Recvpointer = 1 Then Setword Syncpipe , Os_syncpipe_hdr_senddata_ptr , 0 Setword Syncpipe , Os_syncpipe_hdr_recvdata_ptr , 0 Os_exit_critical Else Os_mem_copy Sendpointer , Recvpointer , Size Recvpointer = Getword(Syncpipe , Os_syncpipe_hdr_recvtask_ptr) Setword Syncpipe , Os_syncpipe_hdr_senddata_ptr , 1 Setword Syncpipe , Os_syncpipe_hdr_recvdata_ptr , 0 Os_exit_critical Os_event_task = Recvpointer Os_task_event End If Os_syncpipe_send = True End Function