r4684@vps: verhaegs | 2007-05-04 21:04:10 -0400
[AROS.git] / rom / exec / putmsg.c
blob3432082410e5e2c8e51bbecbec4cbf8ba9a71968
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Send a message to a port.
6 Lang: english
7 */
8 #include "exec_intern.h"
9 #include <aros/libcall.h>
10 #include <exec/ports.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
17 AROS_LH2(void, PutMsg,
19 /* SYNOPSIS */
20 AROS_LHA(struct MsgPort *, port, A0),
21 AROS_LHA(struct Message *, message, A1),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 61, Exec)
26 /* FUNCTION
27 Sends a message to a given message port. Messages are not copied
28 from one task to another but must lie in shared memory instead.
29 Therefore the owner of the message may generally not reuse it before
30 it is returned. But this depends on the two tasks sharing the message.
32 INPUTS
33 port - Pointer to messageport.
34 message - Pointer to message.
36 RESULT
38 NOTES
39 It is legal to send a message from within interrupts.
41 Messages may either trigger a signal at the owner of the messageport
42 or raise a software interrupt, depending on port->mp_Flags&PF_ACTION.
44 EXAMPLE
46 BUGS
48 SEE ALSO
49 WaitPort(), GetMsg()
51 INTERNALS
53 ******************************************************************************/
55 AROS_LIBFUNC_INIT
56 ASSERT_VALID_PTR(message);
57 ASSERT_VALID_PTR(port);
60 Messages may be sent from interrupts. Therefore the message list
61 of the message port must be protected with Disable().
63 Disable();
65 /* Set the node type to NT_MESSAGE == sent message. */
66 message->mn_Node.ln_Type=NT_MESSAGE;
68 /* Add it to the message list. */
69 AddTail(&port->mp_MsgList,&message->mn_Node);
71 if(port->mp_SigTask)
73 ASSERT_VALID_PTR(port->mp_SigTask);
75 /* And trigger the action. */
76 switch(port->mp_Flags & PF_ACTION)
78 case PA_SIGNAL:
79 /* Send the signal */
80 Signal((struct Task *)port->mp_SigTask,1<<port->mp_SigBit);
81 break;
83 case PA_SOFTINT:
84 /* Raise a software interrupt */
85 Cause((struct Interrupt *)port->mp_SoftInt);
86 break;
88 case PA_IGNORE:
89 /* Do nothing. */
90 break;
94 /* All done. */
95 Enable();
96 AROS_LIBFUNC_EXIT
97 } /* PutMsg() */