Rev 3597 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3597 | Rev 4377 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | #include <task.h> |
36 | #include <task.h> |
37 | #include <libc.h> |
37 | #include <libc.h> |
38 | #include <stdlib.h> |
38 | #include <stdlib.h> |
39 | #include <errno.h> |
39 | #include <errno.h> |
40 | #include <loader/loader.h> |
40 | #include <loader/loader.h> |
- | 41 | #include <string.h> |
|
41 | 42 | ||
42 | task_id_t task_get_id(void) |
43 | task_id_t task_get_id(void) |
43 | { |
44 | { |
44 | task_id_t task_id; |
45 | task_id_t task_id; |
45 | 46 | ||
46 | (void) __SYSCALL1(SYS_TASK_GET_ID, (sysarg_t) &task_id); |
47 | (void) __SYSCALL1(SYS_TASK_GET_ID, (sysarg_t) &task_id); |
47 | 48 | ||
48 | return task_id; |
49 | return task_id; |
49 | } |
50 | } |
50 | 51 | ||
- | 52 | /** Set the task name. |
|
- | 53 | * |
|
- | 54 | * @param name The new name, typically the command used to execute the |
|
- | 55 | * program. |
|
- | 56 | * @return Zero on success or negative error code. |
|
- | 57 | */ |
|
- | 58 | int task_set_name(const char *name) |
|
- | 59 | { |
|
- | 60 | return __SYSCALL2(SYS_TASK_SET_NAME, (sysarg_t) name, str_size(name)); |
|
- | 61 | } |
|
- | 62 | ||
51 | /** Create a new task by running an executable from the filesystem. |
63 | /** Create a new task by running an executable from the filesystem. |
52 | * |
64 | * |
53 | * This is really just a convenience wrapper over the more complicated |
65 | * This is really just a convenience wrapper over the more complicated |
54 | * loader API. |
66 | * loader API. |
55 | * |
67 | * |
Line 61... | Line 73... | ||
61 | { |
73 | { |
62 | loader_t *ldr; |
74 | loader_t *ldr; |
63 | task_id_t task_id; |
75 | task_id_t task_id; |
64 | int rc; |
76 | int rc; |
65 | 77 | ||
66 | /* Spawn a program loader. */ |
78 | /* Connect to a program loader. */ |
67 | ldr = loader_spawn(path); |
79 | ldr = loader_connect(); |
68 | if (ldr == NULL) |
80 | if (ldr == NULL) |
69 | return 0; |
81 | return 0; |
70 | 82 | ||
71 | /* Get task ID. */ |
83 | /* Get task ID. */ |
72 | rc = loader_get_task_id(ldr, &task_id); |
84 | rc = loader_get_task_id(ldr, &task_id); |
Line 87... | Line 99... | ||
87 | rc = loader_load_program(ldr); |
99 | rc = loader_load_program(ldr); |
88 | if (rc != EOK) |
100 | if (rc != EOK) |
89 | goto error; |
101 | goto error; |
90 | 102 | ||
91 | /* Run it. */ |
103 | /* Run it. */ |
92 | /* Load the program. */ |
- | |
93 | rc = loader_run(ldr); |
104 | rc = loader_run(ldr); |
94 | if (rc != EOK) |
105 | if (rc != EOK) |
95 | goto error; |
106 | goto error; |
96 | 107 | ||
97 | /* Success */ |
108 | /* Success */ |