Subversion Repositories HelenOS

Rev

Rev 2131 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2131 Rev 2307
Line 122... Line 122...
122
 * stack and userspace argument structure for it.
122
 * stack and userspace argument structure for it.
123
 *
123
 *
124
 * @param function Function implementing the thread.
124
 * @param function Function implementing the thread.
125
 * @param arg Argument to be passed to thread.
125
 * @param arg Argument to be passed to thread.
126
 * @param name Symbolic name of the thread.
126
 * @param name Symbolic name of the thread.
-
 
127
 * @param tid Thread ID of the newly created thread.
127
 *
128
 *
128
 * @return TID of the new thread on success or -1 on failure.
129
 * @return Zero on success or a code from @ref errno.h on failure.
129
 */
130
 */
130
int thread_create(void (* function)(void *), void *arg, char *name)
131
int thread_create(void (* function)(void *), void *arg, char *name, thread_id_t *tid)
131
{
132
{
132
    char *stack;
133
    char *stack;
133
    uspace_arg_t *uarg;
134
    uspace_arg_t *uarg;
134
 
135
 
135
    stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO);
136
    stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO);
Line 146... Line 147...
146
    uarg->uspace_stack = (void *) stack;
147
    uarg->uspace_stack = (void *) stack;
147
    uarg->uspace_thread_function = function;
148
    uarg->uspace_thread_function = function;
148
    uarg->uspace_thread_arg = arg;
149
    uarg->uspace_thread_arg = arg;
149
    uarg->uspace_uarg = uarg;
150
    uarg->uspace_uarg = uarg;
150
   
151
   
151
    return __SYSCALL2(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name);
152
    return __SYSCALL3(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name, (sysarg_t) tid);
152
}
153
}
153
 
154
 
154
/** Terminate current thread.
155
/** Terminate current thread.
155
 *
156
 *
156
 * @param status Exit status. Currently not used.
157
 * @param status Exit status. Currently not used.
Line 158... Line 159...
158
void thread_exit(int status)
159
void thread_exit(int status)
159
{
160
{
160
    __SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status);
161
    __SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status);
161
}
162
}
162
 
163
 
-
 
164
/** Detach thread.
-
 
165
 *
-
 
166
 * Currently not implemented.
-
 
167
 *
-
 
168
 * @param thread TID.
-
 
169
 */
-
 
170
void thread_detach(thread_id_t thread)
-
 
171
{
-
 
172
}
-
 
173
 
-
 
174
/** Join thread.
-
 
175
 *
-
 
176
 * Currently not implemented.
-
 
177
 *
-
 
178
 * @param thread TID.
-
 
179
 *
-
 
180
 * @return Thread exit status.
-
 
181
 */
-
 
182
int thread_join(thread_id_t thread)
-
 
183
{
-
 
184
}
-
 
185
 
-
 
186
/** Get current thread ID.
-
 
187
 *
-
 
188
 * @return Current thread ID.
-
 
189
 */
-
 
190
thread_id_t thread_get_id(void)
-
 
191
{
-
 
192
    thread_id_t thread_id;
-
 
193
 
-
 
194
    (void) __SYSCALL1(SYS_THREAD_GET_ID, (sysarg_t) &thread_id);
-
 
195
 
-
 
196
    return thread_id;
-
 
197
}
-
 
198
 
163
/** @}
199
/** @}
164
 */
200
 */