base/ipc/msg/msg.c File Reference


Detailed Description

Message handling functions.

Author:
Paolo Mantegazza
Note:
Copyright (C) 1999-2003 Paolo Mantegazza <mantegazza@aero.polimi.it> [ Specific COPYRIGHTS follow along the code ]
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Definition in file msg.c.#include <rtai_schedcore.h>
#include <asm/uaccess.h>
#include "rtai_registry.h"
#include "rtai_msg.h"

Include dependency graph for msg.c:

Include dependency graph

Go to the source code of this file.

Defines

#define SET_RPC_MCB()
#define task_mcb   (task->mcb)
#define SET_SEND_MCB()
#define DO_RCV_MSG()

Functions

 MODULE_LICENSE ("GPL")
void reset_task_prio (RT_TASK *task)
RT_TASKrt_send (RT_TASK *task, unsigned long msg)
 Send a message.
RT_TASKrt_send_if (RT_TASK *task, unsigned long msg)
 Send a message, only if the calling task will not be blocked.
RT_TASKrt_send_until (RT_TASK *task, unsigned long msg, RTIME time)
RT_TASKrt_send_timed (RT_TASK *task, unsigned long msg, RTIME delay)
RT_TASKrt_rpc (RT_TASK *task, unsigned long to_do, void *result)
 Make a remote procedure call.
RT_TASKrt_rpc_if (RT_TASK *task, unsigned long to_do, void *result)
 Make a remote procedure call, only if the calling task will not be blocked.
RT_TASKrt_rpc_until (RT_TASK *task, unsigned long to_do, void *result, RTIME time)
 Make a remote procedure call with an absolute timeout.
RT_TASKrt_rpc_timed (RT_TASK *task, unsigned long to_do, void *result, RTIME delay)
 Make a remote procedure call with a relative timeout.
int rt_isrpc (RT_TASK *task)
 Check if sender waits for reply or not.
RT_TASKrt_return (RT_TASK *task, unsigned long result)
 Return (sends) the result back to the task that made the related remote procedure call.
RT_TASKrt_evdrp (RT_TASK *task, void *msg)
 Eavedrop (spy) the content of a message.
RT_TASKrt_receive (RT_TASK *task, void *msg)
 Receive a message.
RT_TASKrt_receive_if (RT_TASK *task, void *msg)
 Receive a message, only if the calling task is not blocked.
RT_TASKrt_receive_until (RT_TASK *task, void *msg, RTIME time)
 Receive a message with an absolute timeout.
RT_TASKrt_receive_timed (RT_TASK *task, void *msg, RTIME delay)
 Receive a message with a relative timeout.
RT_TASKrt_rpcx (RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize)
 Make an extended remote procedure call.
RT_TASKrt_rpcx_if (RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize)
 Make an extended remote procedure call, only if the calling task will not be blocked.
RT_TASKrt_rpcx_until (RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize, RTIME time)
 Make an extended remote procedure call with absolute timeout.
RT_TASKrt_rpcx_timed (RT_TASK *task, void *smsg, void *rmsg, int ssize, int rsize, RTIME delay)
 Make an extended remote procedure call with a relative timeout.
RT_TASKrt_sendx (RT_TASK *task, void *msg, int size)
 Send an extended message.
RT_TASKrt_sendx_if (RT_TASK *task, void *msg, int size)
 Send an extended message, only if the calling task will not be blocked.
RT_TASKrt_sendx_until (RT_TASK *task, void *msg, int size, RTIME time)
 Send an extended message with absolute timeout.
RT_TASKrt_sendx_timed (RT_TASK *task, void *msg, int size, RTIME delay)
 Send an extended message with relative timeout.
RT_TASKrt_returnx (RT_TASK *task, void *msg, int size)
 Return (sends) an extended result back to the task that made the related extended remote procedure call.
RT_TASKrt_evdrpx (RT_TASK *task, void *msg, int size, int *len)
 Eavedrop (spy) the content of an extended message.
RT_TASKrt_receivex (RT_TASK *task, void *msg, int size, int *len)
 Receive an extended message.
RT_TASKrt_receivex_if (RT_TASK *task, void *msg, int size, int *len)
 Receive an extended message, only if the calling task is not blocked.
RT_TASKrt_receivex_until (RT_TASK *task, void *msg, int size, int *len, RTIME time)
 Receive an extended message with an absolute timeout.
RT_TASKrt_receivex_timed (RT_TASK *task, void *msg, int size, int *len, RTIME delay)
 Receive an extended message with a relative timeout.
void proxy_task (RT_TASK *me)
RT_TASK__rt_proxy_attach (void(*agent)(long), RT_TASK *task, void *msg, int nbytes, int priority)
RT_TASKrt_proxy_attach (RT_TASK *task, void *msg, int nbytes, int prio)
int rt_proxy_detach (RT_TASK *proxy)
RT_TASKrt_trigger (RT_TASK *proxy)
int rt_Send (pid_t pid, void *smsg, void *rmsg, size_t ssize, size_t rsize)
pid_t rt_Receive (pid_t pid, void *msg, size_t maxsize, size_t *msglen)
pid_t rt_Creceive (pid_t pid, void *msg, size_t maxsize, size_t *msglen, RTIME delay)
int rt_Reply (pid_t pid, void *msg, size_t size)
void Proxy_Task (RT_TASK *me)
pid_t rt_Proxy_attach (pid_t pid, void *msg, int nbytes, int prio)
int rt_Proxy_detach (pid_t pid)
pid_t rt_Trigger (pid_t pid)
pid_t rt_Name_attach (const char *argname)
pid_t rt_Name_locate (const char *arghost, const char *argname)
int rt_Name_detach (pid_t pid)
int __rtai_msg_init (void)
void __rtai_msg_exit (void)
 module_init (__rtai_msg_init)
 module_exit (__rtai_msg_exit)
 EXPORT_SYMBOL (rt_send)
 EXPORT_SYMBOL (rt_rpc)
 EXPORT_SYMBOL (rt_isrpc)
 EXPORT_SYMBOL (rt_return)
 EXPORT_SYMBOL (rt_evdrp)
 EXPORT_SYMBOL (rt_receive)
 EXPORT_SYMBOL (__rt_proxy_attach)
 EXPORT_SYMBOL (rt_proxy_attach)
 EXPORT_SYMBOL (rt_proxy_detach)
 EXPORT_SYMBOL (rt_trigger)
 EXPORT_SYMBOL (rt_Send)
 EXPORT_SYMBOL (rt_Receive)
 EXPORT_SYMBOL (rt_Creceive)
 EXPORT_SYMBOL (rt_Reply)
 EXPORT_SYMBOL (rt_Proxy_attach)
 EXPORT_SYMBOL (rt_Proxy_detach)
 EXPORT_SYMBOL (rt_Trigger)
 EXPORT_SYMBOL (rt_Name_attach)
 EXPORT_SYMBOL (rt_Name_locate)
 EXPORT_SYMBOL (rt_Name_detach)

Variables

rt_native_fun_entry rt_msg_entries []


Define Documentation

 
#define DO_RCV_MSG  ) 
 

Value:

do { \ if ((*len = size <= mcb->sbytes ? size : mcb->sbytes)) { \ memcpy(msg, mcb->sbuf, *len); \ } \ } while (0)
Definition at line 1551 of file msg.c.

Referenced by rt_evdrpx(), rt_receivex(), rt_receivex_if(), rt_receivex_timed(), and rt_receivex_until().

 
#define SET_RPC_MCB  ) 
 

Value:

do { \ mcb.sbuf = smsg; \ mcb.sbytes = ssize; \ mcb.rbuf = rmsg; \ mcb.rbytes = rsize; \ } while (0)
Definition at line 1095 of file msg.c.

Referenced by rt_rpcx(), rt_rpcx_if(), rt_rpcx_timed(), and rt_rpcx_until().

 
#define SET_SEND_MCB  ) 
 

Value:

do { \ task_mcb.sbuf = msg; \ task_mcb.sbytes = size; \ task_mcb.rbuf = 0; \ task_mcb.rbytes = 0; \ } while (0)
Definition at line 1307 of file msg.c.

Referenced by rt_sendx(), rt_sendx_if(), rt_sendx_timed(), and rt_sendx_until().

#define task_mcb   (task->mcb)
 

Definition at line 1306 of file msg.c.

Referenced by rt_sendx(), rt_sendx_if(), rt_sendx_timed(), and rt_sendx_until().


Function Documentation

RT_TASK* __rt_proxy_attach void(*  agent)(long),
RT_TASK task,
void *  msg,
int  nbytes,
int  priority
 

Definition at line 1836 of file msg.c.

References rt_free(), rt_kthread_init(), rt_malloc(), RT_SCHED_LINUX_PRIORITY, RT_SCHED_LOWEST_PRIORITY, RT_TASK, and task.

Referenced by rt_Proxy_attach(), and rt_proxy_attach().

Here is the call graph for this function:

void __rtai_msg_exit void   ) 
 

Definition at line 2156 of file msg.c.

References reset_rt_fun_entries(), and rt_msg_entries.

Here is the call graph for this function:

int __rtai_msg_init void   ) 
 

Definition at line 2151 of file msg.c.

References rt_msg_entries, and set_rt_fun_entries().

Here is the call graph for this function:

EXPORT_SYMBOL rt_Name_detach   ) 
 

EXPORT_SYMBOL rt_Name_locate   ) 
 

EXPORT_SYMBOL rt_Name_attach   ) 
 

EXPORT_SYMBOL rt_Trigger   ) 
 

EXPORT_SYMBOL rt_Proxy_detach   ) 
 

EXPORT_SYMBOL rt_Proxy_attach   ) 
 

EXPORT_SYMBOL rt_Reply   ) 
 

EXPORT_SYMBOL rt_Creceive   ) 
 

EXPORT_SYMBOL rt_Receive   ) 
 

EXPORT_SYMBOL rt_Send   ) 
 

EXPORT_SYMBOL rt_trigger   ) 
 

EXPORT_SYMBOL rt_proxy_detach   ) 
 

EXPORT_SYMBOL rt_proxy_attach   ) 
 

EXPORT_SYMBOL __rt_proxy_attach   ) 
 

EXPORT_SYMBOL rt_receive   ) 
 

EXPORT_SYMBOL rt_evdrp   ) 
 

EXPORT_SYMBOL rt_return   ) 
 

EXPORT_SYMBOL rt_isrpc   ) 
 

EXPORT_SYMBOL rt_rpc   ) 
 

EXPORT_SYMBOL rt_send   ) 
 

module_exit __rtai_msg_exit   ) 
 

module_init __rtai_msg_init   ) 
 

MODULE_LICENSE "GPL"   ) 
 

void Proxy_Task RT_TASK me  )  [static]
 

Definition at line 2003 of file msg.c.

References MSGCB, rt_rpc(), RT_TASK, and rt_task_suspend().

Referenced by rt_Proxy_attach().

Here is the call graph for this function:

void proxy_task RT_TASK me  )  [static]
 

Definition at line 1820 of file msg.c.

References rt_rpc(), RT_TASK, and rt_task_suspend().

Referenced by rt_proxy_attach().

Here is the call graph for this function:

void reset_task_prio RT_TASK task  )  [inline, static]
 

Definition at line 46 of file msg.c.

References RT_TASK, and task.

Referenced by rt_rpc_until().

pid_t rt_Creceive pid_t  pid,
void *  msg,
size_t  maxsize,
size_t *  msglen,
RTIME  delay
 

Definition at line 1957 of file msg.c.

References MSGCB, pid, rt_receive_if(), rt_receive_timed(), RT_TASK, RTIME, and task.

Here is the call graph for this function:

pid_t rt_Name_attach const char *  argname  ) 
 

Definition at line 2056 of file msg.c.

References RT_TASK, RTAI_MAX_NAME_LENGTH, task, TSKEXT0, and TSKEXT1.

int rt_Name_detach pid_t  pid  )  [inline]
 

Definition at line 2086 of file msg.c.

References BIDX, rtai_lxrt_t::i, LOW, pid, RT_NAME_DETACH, RT_TASK, rtai_lxrt(), SIZARG, TSKEXT0, and TSKEXT1.

Here is the call graph for this function:

pid_t rt_Name_locate const char *  arghost,
const char *  argname
[inline]
 

Definition at line 2069 of file msg.c.

References BIDX, cpuid, rtai_lxrt_t::i, LOW, nam2num(), rt_get_adr(), RT_NAME_LOCATE, rt_smp_linux_task, RT_TASK, rtai_lxrt(), RTAI_MAX_NAME_LENGTH, SIZARG, task, and TSKEXT1.

Here is the call graph for this function:

pid_t rt_Proxy_attach pid_t  pid,
void *  msg,
int  nbytes,
int  prio
 

Definition at line 2023 of file msg.c.

References __rt_proxy_attach(), pid, Proxy_Task(), RT_TASK, and task.

Here is the call graph for this function:

RT_TASK* rt_proxy_attach RT_TASK task,
void *  msg,
int  nbytes,
int  prio
 

Definition at line 1876 of file msg.c.

References __rt_proxy_attach(), proxy_task(), RT_TASK, and task.

Here is the call graph for this function:

int rt_Proxy_detach pid_t  pid  ) 
 

Definition at line 2029 of file msg.c.

References pid, rt_free(), RT_TASK, and rt_task_delete().

Here is the call graph for this function:

int rt_proxy_detach RT_TASK proxy  ) 
 

Definition at line 1883 of file msg.c.

References rt_free(), RT_TASK, and rt_task_delete().

Here is the call graph for this function:

pid_t rt_Receive pid_t  pid,
void *  msg,
size_t  maxsize,
size_t *  msglen
 

Definition at line 1940 of file msg.c.

References MSGCB, pid, rt_receive(), RT_TASK, and task.

Here is the call graph for this function:

int rt_Reply pid_t  pid,
void *  msg,
size_t  size
 

Definition at line 1980 of file msg.c.

References MSGCB, pid, rt_return(), RT_TASK, and task.

Here is the call graph for this function:

RT_TASK* rt_rpcx RT_TASK task,
void *  smsg,
void *  rmsg,
int  ssize,
int  rsize
 

Make an extended remote procedure call.

rt_rpcx makes an extended Remote Procedure Call (RPC). rt_rpcx is used for synchronous inter task messaging. It sends an arbitrary smsg of size ssize bytes to the task task then it always blocks waiting until a message, of size rsize bytes at most, is returned in rmsg from the called task. If the returned message is greater tha rsize it will be truncated. So the caller task is always blocked on the receiver priority queue while the receiver inheredits the blocked sender priority if it is higher (lower in value) than its. The receiver task may get the message with any rt_receivex function. It can send an answer with rt_returnx().

Parameters:
task pointer to the RT_TASK structure of the receiver.
smsg points to the message to be sent.
rmsg points to the message to be returned by the receiver.
ssize size of the message to be sent.
rsize maximum allowed size for the message to be received.
Returns:
On success, task (the pointer to the task that received the message) is returned. If the message has not been sent (e.g. the task task was killed before receiving the message) 0 is returned.
See also: rt_receivex_*, rt_returnx(), rt_isrpc().

Note:
The trio rt_rpcx(), rt_receivex(), rt_returnx() implements functions similar to its peers send-receive-reply found in QNX. For a even greater compatibility see rt_Send-rt_Receive-rt_Reply.
Definition at line 1139 of file msg.c.

References rt_rpc(), RT_TASK, SET_RPC_MCB, and task.

Referenced by RT_rpcx().

Here is the call graph for this function:

RT_TASK* rt_rpcx_if RT_TASK task,
void *  smsg,
void *  rmsg,
int  ssize,
int  rsize
 

Make an extended remote procedure call, only if the calling task will not be blocked.

rt_rpcx_if tries to make an extended Remote Procedure Call (RPC). If the receiver task is ready to accept a message rt_rpcx_if sends the message as it will be done by rt_rpcx. If the receiver is not ready rt_rpcx_if returns immediately. The receiver task may get the message with any rt_receivex function. It can send the answer with * rt_returnx().

Parameters:
task pointer to the RT_TASK structure of the receiver.
smsg points to the message to be sent.
rmsg points to the message to be returned by the receiver.
ssize size of the message to be sent.
rsize maximum allowed size for the message to be received.
Returns:
On success, task (the pointer to the task that received the message) is returned. If message has not been sent, 0 is returned. On other failure, a special value is returned as described below:
  • 0: The task task was not ready to receive the message or it was killed before sending the reply.
  • 0xFFFF: task does not refer to a valid task.
See also: notes under rt_rpc().

Note:
Since all the messaging functions return a task address, 0xFFFF could seem an inappropriate return value. However on all the CPUs RTAI runs on, 0xFFFF is not an address that can be used by any RTAI task, so it is should be always safe.
Definition at line 1188 of file msg.c.

References rt_rpc_if(), RT_TASK, SET_RPC_MCB, and task.

Referenced by RT_rpcx_if().

Here is the call graph for this function:

int rt_Send pid_t  pid,
void *  smsg,
void *  rmsg,
size_t  ssize,
size_t  rsize
 

Definition at line 1918 of file msg.c.

References MSGCB, pid, rt_rpc(), RT_TASK, and task.

Here is the call graph for this function:

pid_t rt_Trigger pid_t  pid  ) 
 

Definition at line 2039 of file msg.c.

References atomic_inc(), pid, RT_TASK, and rt_task_resume().

Here is the call graph for this function:

RT_TASK* rt_trigger RT_TASK proxy  ) 
 

Definition at line 1893 of file msg.c.

References atomic_inc(), RT_TASK, and rt_task_resume().

Here is the call graph for this function:


Variable Documentation

struct rt_native_fun_entry rt_msg_entries[]
 

Definition at line 2103 of file msg.c.

Referenced by __rtai_msg_exit(), and __rtai_msg_init().


Generated on Thu Nov 20 11:55:00 2008 for RTAI API by doxygen 1.3.8