Prex Home / Browse Source - Prex Version: 0.9.0

root/sys/include/task.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*-
   2  * Copyright (c) 2005-2006, Kohsuke Ohtani
   3  * All rights reserved.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 1. Redistributions of source code must retain the above copyright
   9  *    notice, this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright
  11  *    notice, this list of conditions and the following disclaimer in the
  12  *    documentation and/or other materials provided with the distribution.
  13  * 3. Neither the name of the author nor the names of any co-contributors
  14  *    may be used to endorse or promote products derived from this software
  15  *    without specific prior written permission.
  16  *
  17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27  * SUCH DAMAGE.
  28  */
  29 
  30 #ifndef _TASK_H
  31 #define _TASK_H
  32 
  33 #include <types.h>
  34 #include <sys/cdefs.h>
  35 #include <sys/list.h>
  36 #include <sys/capability.h>     /* for cap_t */
  37 #include <sys/sysinfo.h>
  38 #include <thread.h>
  39 #include <timer.h>
  40 
  41 /*
  42  * Task struct
  43  */
  44 struct task {
  45         struct list     link;           /* linkage on task list in system */
  46         char            name[MAXTASKNAME]; /* task name */
  47         task_t          parent;         /* parent task */
  48         vm_map_t        map;            /* address space description */
  49         int             suscnt;         /* suspend count */
  50         int             flags;          /* flags defined below */
  51         cap_t           capability;     /* security permission flag */
  52         struct timer    alarm;          /* timer for alarm exception */
  53         void            (*handler)(int); /* pointer to exception handler */
  54         struct list     threads;        /* list of threads */
  55         struct list     objects;        /* IPC objects owned by this task */
  56         struct list     mutexes;        /* mutexes owned by this task */
  57         struct list     conds;          /* cv owned by this task */
  58         struct list     sems;           /* semaphores owned by this task */
  59         int             nthreads;       /* number of threads */
  60         int             nobjects;       /* number of IPC objects */
  61         int             nsyncs;         /* number of syncronizer objects */
  62 };
  63 
  64 #define curtask         (curthread->task)
  65 
  66 /* flags */
  67 #define TF_SYSTEM       0x00000001 /* kernel task (kern_task) */
  68 #define TF_TRACE        0x00000002 /* process system call tracing active */
  69 #define TF_PROFIL       0x00000004 /* has started profiling */
  70 #define TF_AUDIT        0x00000008 /* audit mode */
  71 
  72 /* default flags */
  73 #ifdef CONFIG_AUDIT
  74 #define TF_DEFAULT      TF_AUDIT
  75 #else
  76 #define TF_DEFAULT      0
  77 #endif
  78 
  79 /* vm option for task_create(). */
  80 #define VM_NEW          0       /* create new memory map */
  81 #define VM_SHARE        1       /* share parent's memory map */
  82 #define VM_COPY         2       /* duplicate parent's memory map */
  83 
  84 __BEGIN_DECLS
  85 int      task_create(task_t, int, task_t *);
  86 int      task_terminate(task_t);
  87 task_t   task_self(void);
  88 int      task_suspend(task_t);
  89 int      task_resume(task_t);
  90 int      task_setname(task_t, const char *);
  91 int      task_setcap(task_t, cap_t);
  92 int      task_chkcap(task_t, cap_t);
  93 int      task_capable(cap_t);
  94 int      task_valid(task_t);
  95 int      task_access(task_t);
  96 int      task_info(struct taskinfo *);
  97 void     task_bootstrap(void);
  98 void     task_init(void);
  99 __END_DECLS
 100 
 101 #endif /* !_TASK_H */

/* [<][>][^][v][top][bottom][index][help] */