Annotation of prex/sys/include/task.h, Revision 1.1
1.1 ! nbrk 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 <prex/capability.h> /* for cap_t */
! 34: #include <timer.h>
! 35:
! 36: /*
! 37: * Task struct
! 38: */
! 39: struct task {
! 40: int magic; /* magic number */
! 41: char name[MAXTASKNAME]; /* task name */
! 42: struct list link; /* link for all tasks in system */
! 43: struct list objects; /* objects owned by this task */
! 44: struct list threads; /* threads in this task */
! 45: vm_map_t map; /* address space description */
! 46: int suscnt; /* suspend counter */
! 47: cap_t capability; /* security permission flag */
! 48: struct timer alarm; /* alarm timer */
! 49: void (*handler)(int); /* pointer to excepion handler */
! 50: task_t parent; /* parent task */
! 51: };
! 52:
! 53: #define cur_task() (cur_thread->task)
! 54: #define task_valid(tsk) (kern_area(tsk) && ((tsk)->magic == TASK_MAGIC))
! 55: #define task_capable(cap) ((int)(cur_task()->capability & (cap)))
! 56:
! 57: /* vm option for task_create(). */
! 58: #define VM_NEW 0 /* Create new memory map */
! 59: #define VM_SHARE 1 /* Share parent's memory map */
! 60: #define VM_COPY 2 /* Duplicate parent's memory map */
! 61:
! 62: extern int task_create(task_t, int, task_t *);
! 63: extern int task_terminate(task_t);
! 64: extern task_t task_self(void);
! 65: extern int task_suspend(task_t);
! 66: extern int task_resume(task_t);
! 67: extern int task_name(task_t, const char *);
! 68: extern int task_getcap(task_t, cap_t *);
! 69: extern int task_setcap(task_t, cap_t *);
! 70: extern int task_access(task_t);
! 71: extern void task_bootstrap(void);
! 72: extern void task_dump(void);
! 73: extern void task_init(void);
! 74:
! 75: #endif /* !_TASK_H */
CVSweb