source: mainline/uspace/lib/c/include/ipc/ipc.h@ dd8b6a8

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since dd8b6a8 was 1c635d6, checked in by Martin Sucha <sucha14@…>, 11 years ago

Do not hold a task's return value after it has disconnected.

Holding the task's return value meant that if nobody waited
for task's result, it polluted NS's memory. This was apparently
done because of a race between spawning a task and waiting for it.

We solve this problem in another way: ns discards the return value
as soon as the task disconnects from it. This typically happens
when the task finishes its execution. In order to avoid the race,
we send the wait request to ns while spawning the task (i.e. when
we talk to the loader), but before we allow the loaded program
to run.

Fixes #132

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*
2 * Copyright (c) 2006 Ondrej Palkovsky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libcipc
30 * @{
31 */
32/** @file
33 */
34
35#if ((defined(LIBC_ASYNC_H_)) && (!defined(LIBC_ASYNC_C_)))
36 #error Do not intermix low-level IPC interface and async framework
37#endif
38
39#ifndef LIBC_IPC_H_
40#define LIBC_IPC_H_
41
42#include <sys/types.h>
43#include <ipc/common.h>
44#include <abi/ipc/methods.h>
45#include <abi/synch.h>
46#include <abi/proc/task.h>
47
48typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
49
50extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
51extern void ipc_poke(void);
52
53#define ipc_wait_for_call(data) \
54 ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
55
56extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);
57extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
58
59/*
60 * User-friendly wrappers for ipc_answer_fast() and ipc_answer_slow().
61 * They are in the form of ipc_answer_m(), where m is the number of return
62 * arguments. The macros decide between the fast and the slow version according
63 * to m.
64 */
65
66#define ipc_answer_0(callid, retval) \
67 ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
68#define ipc_answer_1(callid, retval, arg1) \
69 ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0)
70#define ipc_answer_2(callid, retval, arg1, arg2) \
71 ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0)
72#define ipc_answer_3(callid, retval, arg1, arg2, arg3) \
73 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0)
74#define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \
75 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4))
76#define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \
77 ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
78
79extern sysarg_t ipc_answer_fast(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
80 sysarg_t, sysarg_t);
81extern sysarg_t ipc_answer_slow(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
82 sysarg_t, sysarg_t, sysarg_t);
83
84/*
85 * User-friendly wrappers for ipc_call_async_fast() and ipc_call_async_slow().
86 * They are in the form of ipc_call_async_m(), where m is the number of payload
87 * arguments. The macros decide between the fast and the slow version according
88 * to m.
89 */
90
91#define ipc_call_async_0(phoneid, method, private, callback, can_preempt) \
92 ipc_call_async_fast((phoneid), (method), 0, 0, 0, 0, (private), \
93 (callback), (can_preempt))
94#define ipc_call_async_1(phoneid, method, arg1, private, callback, \
95 can_preempt) \
96 ipc_call_async_fast((phoneid), (method), (arg1), 0, 0, 0, (private), \
97 (callback), (can_preempt))
98#define ipc_call_async_2(phoneid, method, arg1, arg2, private, callback, \
99 can_preempt) \
100 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
101 (private), (callback), (can_preempt))
102#define ipc_call_async_3(phoneid, method, arg1, arg2, arg3, private, callback, \
103 can_preempt) \
104 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
105 (private), (callback), (can_preempt))
106#define ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, private, \
107 callback, can_preempt) \
108 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), \
109 (arg4), (private), (callback), (can_preempt))
110#define ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, \
111 private, callback, can_preempt) \
112 ipc_call_async_slow((phoneid), (method), (arg1), (arg2), (arg3), \
113 (arg4), (arg5), (private), (callback), (can_preempt))
114
115extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
116 sysarg_t, void *, ipc_async_callback_t, bool);
117extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
118 sysarg_t, sysarg_t, void *, ipc_async_callback_t, bool);
119
120extern int ipc_hangup(int);
121
122extern int ipc_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
123 unsigned int);
124extern int ipc_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
125 sysarg_t, sysarg_t, sysarg_t, unsigned int);
126
127extern int ipc_connect_kbox(task_id_t);
128
129#endif
130
131/** @}
132 */
Note: See TracBrowser for help on using the repository browser.