summaryrefslogtreecommitdiffstats
path: root/src/lib/syscall_task.C
blob: 405e4f2020504946883de3ef58a07e65c5ad9fed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <sys/task.h>
#include <sys/syscall.h>
#include <kernel/task.H>
#include <kernel/taskmgr.H>

using namespace Systemcalls;

void task_yield()
{
    _syscall0(TASK_YIELD);
    return;
}

tid_t task_create(void(*fn)(void*), void* ptr)
{
    return (tid_t) _syscall2(TASK_START, (void*)fn, ptr);
}

void task_end()
{
    _syscall0(TASK_END); // no return.
    return;
}

tid_t task_gettid()
{
    // Even though we have a syscall for GETTID, we can implement this as a 
    // direct access to SPRG3.  On processor that do not support unprivilaged
    // access to this SPR, we implement it as an emulated instruction in the
    // exception handler.

    return TaskManager::getCurrentTask()->tid;
    //return (tid_t)_syscall0(TASK_GETTID);
}
OpenPOWER on IntegriCloud