minix/lib/utils/get_proc_nr.c

35 lines
901 B
C
Raw Normal View History

2005-04-21 16:53:53 +02:00
#include "utils.h"
#include <minix/config.h>
#include <timers.h>
#include "../../kernel/const.h"
#include "../../kernel/type.h"
#include "../../kernel/proc.h"
/*===========================================================================*
* get_proc_nr *
*===========================================================================*/
PUBLIC int get_proc_nr(proc_nr, proc_name)
int *proc_nr; /* store process number here */
char *proc_name; /* lookup process by name */
{
2005-04-29 17:36:43 +02:00
static struct proc proc;
2005-04-21 16:53:53 +02:00
message m;
int s;
if (proc_name != NULL) { /* lookup by name */
} else { /* get own process number */
m.m_type = SYS_GETINFO;
m.I_REQUEST = GET_PROC;
m.I_PROC_NR = SELF;
m.I_KEY_LEN = SELF;
m.I_VAL_PTR = (char *) &proc;
2005-04-29 17:36:43 +02:00
m.I_VAL_LEN = 0;
2005-04-21 16:53:53 +02:00
if ((s=_taskcall(SYSTASK, SYS_GETINFO, &m)) != OK)
return(s);
*proc_nr = proc.p_nr;
}
return(OK);
}