[1be7bee] | 1 | /*
|
---|
| 2 | * Copyright (c) 2009 Martin Decky
|
---|
| 3 | * Copyright (c) 2015 Michal Koutny
|
---|
| 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | /** @addtogroup taskman
|
---|
| 31 | * @{
|
---|
| 32 | */
|
---|
| 33 |
|
---|
| 34 | #ifndef TASKMAN_TASK_H__
|
---|
| 35 | #define TASKMAN_TASK_H__
|
---|
| 36 |
|
---|
| 37 | #include <abi/proc/task.h>
|
---|
[035d7d8] | 38 | #include <adt/hash_table.h>
|
---|
| 39 | #include <adt/list.h>
|
---|
| 40 | #include <fibril_synch.h>
|
---|
| 41 | #include <ipc/common.h>
|
---|
| 42 |
|
---|
| 43 | /** What type of retval from the task we have */
|
---|
| 44 | typedef enum {
|
---|
[102f641] | 45 | /* unset */
|
---|
| 46 | RVAL_UNSET,
|
---|
| 47 |
|
---|
| 48 | /* retval set, e.g. by server */
|
---|
| 49 | RVAL_SET,
|
---|
| 50 |
|
---|
| 51 | /* retval set, wait for expected task exit */
|
---|
| 52 | RVAL_SET_EXIT
|
---|
[035d7d8] | 53 | } retval_t;
|
---|
| 54 |
|
---|
| 55 | /** Holds necessary information of each (registered) task. */
|
---|
| 56 | typedef struct {
|
---|
| 57 | ht_link_t link;
|
---|
[102f641] | 58 |
|
---|
| 59 | /* Task id. */
|
---|
| 60 | task_id_t id;
|
---|
| 61 | /* Task's uspace exit status. */
|
---|
| 62 | task_exit_t exit;
|
---|
| 63 | /* Task failed (task can exit unexpectedly even w/out failure). */
|
---|
| 64 | bool failed;
|
---|
| 65 | /* Task returned a value. */
|
---|
| 66 | retval_t retval_type;
|
---|
| 67 | /* The return value. */
|
---|
| 68 | int retval;
|
---|
| 69 | /* Link to listeners list. */
|
---|
| 70 | link_t listeners;
|
---|
| 71 | /* Session for notifications to task. */
|
---|
| 72 | async_sess_t *sess;
|
---|
[035d7d8] | 73 | } task_t;
|
---|
| 74 |
|
---|
[102f641] | 75 | typedef bool (*task_walker_t)(task_t *, void *);
|
---|
[4667b5c] | 76 |
|
---|
[035d7d8] | 77 | extern fibril_rwlock_t task_hash_table_lock;
|
---|
[1be7bee] | 78 |
|
---|
[4667b5c] | 79 | extern int tasks_init(void);
|
---|
[1be7bee] | 80 |
|
---|
[035d7d8] | 81 | extern task_t *task_get_by_id(task_id_t);
|
---|
[1be7bee] | 82 |
|
---|
[4667b5c] | 83 | extern void task_foreach(task_walker_t, void *);
|
---|
| 84 |
|
---|
| 85 | extern void task_remove(task_t **);
|
---|
| 86 |
|
---|
[012dd8e] | 87 | extern int task_intro(task_id_t);
|
---|
[1be7bee] | 88 |
|
---|
| 89 | #endif
|
---|
| 90 |
|
---|
| 91 | /**
|
---|
| 92 | * @}
|
---|
| 93 | */
|
---|