00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #ifndef _PROC_H_ 00010 #define _PROC_H_ 00011 00012 #include <kernel.h> 00013 #include <semaphore.h> 00014 00015 /* process table declarations and defined constants */ 00016 00017 #ifndef NPROC /* if number of processes is not set, */ 00018 #define NPROC 50 00019 #endif 00020 00021 /* unusual value marks the top of the process stack */ 00022 #define STACKMAGIC 0x0A0AAAA9 00023 00024 /* process state constants */ 00025 00026 #define PRCURR 1 00027 #define PRFREE 2 00028 #define PRREADY 3 00029 #define PRRECV 4 00030 #define PRSLEEP 5 00031 #define PRSUSP 6 00032 #define PRWAIT 7 00034 /* miscellaneous process definitions */ 00035 00036 #define PNMLEN 16 00037 /* the null process is always eligible to run */ 00038 #define NULLPROC 0 00039 #define BADPID (-1) 00045 #define isbadpid(x) ((x)>=NPROC || PRFREE == proctab[(x)].state) 00046 00047 /* process table entry */ 00048 00049 typedef struct pentry 00050 { 00051 uchar state; 00052 ushort prio; 00053 void *stkptr; 00054 void *stkbase; 00055 ulong stklen; 00056 char name[PNMLEN]; 00057 irqmask irqstate; 00058 semaphore sem; 00059 ushort parent; 00060 long msg; 00061 bool hasmsg; 00062 } pcb; 00063 00064 /* process initialization constants */ 00065 #define INITSTK 65536 00066 #define INITPRIO 20 00067 #define INITRET userret 00068 #define MINSTK 4096 00069 #define NULLSTK MINSTK 00071 /* reschedule constants for send and receive */ 00072 #define BLOCK 1 00073 #define NOBLOCK 0 00074 00075 00076 extern struct pentry proctab[]; 00077 extern ushort numproc; 00078 extern ushort currpid; 00080 /* IPC prototypes */ 00081 syscall send(ushort pid, long msg, bool block); 00082 syscall receive(bool block); 00083 00084 #endif /* _PROC_H_ */