Download presentation
Presentation is loading. Please wait.
Published byAdam Carter Modified over 9 years ago
1
Nguy ễ n Hoàng Tâm50702111 Nguy ễ n Văn Tr ọ ng50702651
2
Synchronization and communication : ◦ Passing variable-size messages ◦ Holding messages for sending and receiving ◦ 2 queues : messages waiting to be sent ( send queue),tasks waiting for messages receipt ( receive queue).
3
Sender : ◦ Copy message to buffer ◦ If not enough space : message is queued for sending until enough space is available. task waiting to send is put in send queue
4
Receipt : ◦ Message is fetched from buffer ◦ If buffer has no messages : task enter Wait state and put in receive queue What if buffer size is 0 : ◦ Message communication function is synchronous ◦ Task wait for system call to be invoked ◦ Message is passed when both side issue system call
5
Synchronous Communication by Message Buffer
6
tk_cre_mbf : create message buffer ID mbfid = tk_cre_mbf(T_CMBF *pk_cmbf) pk_cmbf details : ◦ VPexinfExtended informations ◦ ATRmbfatrMessage buffer attributes ◦ INTbufszMessage buffer size ( in bytes ) ◦ INTmaxmsz Maximun massage size (in bytes )
7
Error code : - E_OK Normal completion - E_NOMEM Insu ffi cient memory (memory for control block or ring bu ff er area cannot be allocated) - E_LIMIT Number of message bu ff ers exceeds the system limit - E_RSATR Reserved attribute (mbfatr is invalid or cannot be used) - E_PAR Parameter error (pk cmbf is invalid, or bufsz or maxmsz is negative or invalid) mbfatr : - TA_TFIFO Tasks waiting to send are queued in FIFO order - TA_TPRI Tasks waiting to send are queued in priority order - TA_NODISWAI Wait disabling by tk dis wai is prohibited
8
Notes : ◦ Tasks waiting for a message to be sent can be designated in TA_FIFO or TA_PRI ◦ Messages are queued in FIFO order only ◦ Tasks waiting for message receipt are queued in FIFO order only ◦ When there’re multiple tasks waiting to send, the order will always be obeyed in spite of buffer space ( enough or not )
9
tk_del_mbf : delete message buffer ER recd = tk_del_mbf(ID mbfid) Error code : - E_OK : Normal completion - E_ID : Invalid ID number (mbfid is invalid or cannot be used) - E_NOEXS : Object does not exist (the message bu ff er designated in mbfid does not exist)
10
When this functions is called : Release : message buffer space and control block If there’re tasks queued in message buffer, error code E_DLT returned to the tasks in Wait state If there’re message in buffer, it is deleted and no error code is returned
11
tk_snd_mbf : send message to message buffer ER ercd = tk_snd_mbf ( ID mbfid, VP msg, INT msgsz, TMO tmout ) Parameter : - ID mbfid Message bu ff er ID - INT msgsz Send message size (in bytes) - VP msg Start address of send message packet - TMO tmout Timeout designation
12
Error code : - E_OK :Normal completion - E_ID :Invalid ID number (mbfid is invalid or cannot be used) - E_NOEXS : Object does not exist (the message bu ff er designated in mbfid does not exist) - E_PAR : Parameter error (msgsz · 0, msgsz > maxmsz,value that cannot be used in msg, or tmout · (¡2)) - E_DLT : The object being waited for was deleted (message bu ff er was deleted while waiting) - E_RLWAI : Wait state released (tk rel wai received in wait state) - E_DISWAI : Wait released by wait disabled state - E_TMOUT : Polling failed or timeout - E_CTX : Context error (issued from task-independent portion or in dispatch disabled state)
13
Descriptions : ◦ Copy msgsz bytes starting at mgz to message queue of message buffer ◦ If msgsz is larger than maxmsz, error code is returned ◦ If not enough space, task issued this system call goes to wait state ◦ If tmout elapses before wait state releases, system call terminates and return error code ◦ When tmout = T_POL, if there’s enough space, error code return without entering wait state ◦ When tmout = T_FEVR, task continues to wait for buffer space become available
14
tk_recv_mbf : receive message buffer INT msgsz = tk_rcv_mbf ( ID mbfid, VP msg, TMO tmout ) Return message size or error code - Parameter, error code : similar to tk_snd_mbf
15
tk_ref_mbf : get message buffer status ER ercd = tk_ref_mbf ( ID mbfid, T_RMBF *pk_rmbf ) Pk_rmbf details : ◦ VP exinf :Extended information ◦ ID wtsk :Waiting task information ◦ ID stsk :Send task information ◦ INT msgsz :Size of the next message to be received (in bytes) ◦ INT frbufsz :Free bu ff er size (in bytes) ◦ INT maxmsz :Maximum message size (in bytes)
16
Descriptions : ◦ Reference the status of message buffer ◦ If multiple tasks are waiting, return the ID of task at the head of queue ◦ If no task waiting, 0 is returned ◦ If there’s no message at the queue, msgsz = 0 is returned
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.