Commit 06a131cc authored by Philippe Gerum's avatar Philippe Gerum
Browse files

cobalt/kernel/thread: add cobalt_thread_getpid service

This service returns the per-task kernel pid of a local pthread.
parent 5438340e
......@@ -23,7 +23,7 @@
#define COBALT_BINDING_MAGIC 0x50534531
#define sc_cobalt_thread_create 0
/* 1 unimplemented */
#define sc_cobalt_thread_getpid 1
#define sc_cobalt_sched_weightprio 2
#define sc_cobalt_sched_yield 3
/* 4-5 unimplemented */
......@@ -88,6 +88,7 @@ static int cobalt_syscall_ni(void)
static struct xnsyscall cobalt_syscalls[] = {
SKINCALL_DEF(sc_cobalt_thread_create, cobalt_thread_create, init),
SKINCALL_DEF(sc_cobalt_thread_getpid, cobalt_thread_pid, current),
SKINCALL_DEF(sc_cobalt_thread_setschedparam_ex, cobalt_thread_setschedparam_ex, conforming),
SKINCALL_DEF(sc_cobalt_thread_getschedparam_ex, cobalt_thread_getschedparam_ex, current),
SKINCALL_DEF(sc_cobalt_sched_weightprio, cobalt_sched_weighted_prio, current),
......@@ -705,6 +705,30 @@ int cobalt_thread_join(unsigned long pth)
return xnthread_join(&thread->threadbase, false);
pid_t cobalt_thread_pid(unsigned long pth)
struct cobalt_local_hkey hkey;
struct cobalt_thread *thread;
pid_t pid;
spl_t s;
xnlock_get_irqsave(&nklock, s);
hkey.u_pth = pth; = current->mm;
thread = thread_lookup(&hkey);
if (thread == NULL)
pid = -ESRCH;
pid = xnthread_host_pid(&thread->threadbase);
xnlock_put_irqrestore(&nklock, s);
return pid;
int cobalt_thread_stat(pid_t pid,
struct cobalt_threadstat __user *u_stat)
......@@ -128,7 +128,7 @@ struct cobalt_thread *cobalt_thread_find_local(pid_t pid);
struct cobalt_thread *cobalt_thread_lookup(unsigned long pth);
int cobalt_thread_create(unsigned long tid, int policy,
int cobalt_thread_create(unsigned long pth, int policy,
struct sched_param_ex __user *u_param,
int shifted_muxid,
unsigned long __user *u_window_offset);
......@@ -140,24 +140,24 @@ cobalt_thread_shadow(struct task_struct *p,
int cobalt_thread_setmode_np(int clrmask, int setmask, int __user *u_mode_r);
int cobalt_thread_setname_np(unsigned long tid, const char __user *u_name);
int cobalt_thread_setname_np(unsigned long pth, const char __user *u_name);
int cobalt_thread_probe_np(pid_t h_tid);
int cobalt_thread_kill(unsigned long pth, int sig);
int cobalt_thread_kill(unsigned long tid, int sig);
int cobalt_thread_join(unsigned long pth);
int cobalt_thread_join(unsigned long tid);
pid_t cobalt_thread_pid(unsigned long pth);
int cobalt_thread_stat(pid_t pid,
struct cobalt_threadstat __user *u_stat);
int cobalt_thread_setschedparam_ex(unsigned long tid,
int cobalt_thread_setschedparam_ex(unsigned long pth,
int policy,
const struct sched_param_ex __user *u_param,
unsigned long __user *u_window_offset,
int __user *u_promoted);
int cobalt_thread_getschedparam_ex(unsigned long tid,
int cobalt_thread_getschedparam_ex(unsigned long pth,
int __user *u_policy,
struct sched_param_ex __user *u_param);
......@@ -177,11 +177,6 @@ DECLARE_EVENT_CLASS(cobalt_posix_pid,
TP_printk("pid=%d", __entry->pid)
DEFINE_EVENT(cobalt_posix_pid, cobalt_pthread_probe,
TP_PROTO(pid_t pid),
DEFINE_EVENT(cobalt_posix_pid, cobalt_pthread_stat,
TP_PROTO(pid_t pid),
......@@ -213,6 +208,18 @@ TRACE_EVENT(cobalt_pthread_join,
TP_printk("pth=%p", (void *)__entry->pth)
TP_PROTO(unsigned long pth),
__field(unsigned long, pth)
__entry->pth = pth;
TP_printk("pth=%p", (void *)__entry->pth)
TP_PROTO(unsigned long pth, const char *name),
TP_ARGS(pth, name),
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment