root/Whitix/trunk/include/task.h

Revision 2011, 2.6 KB (checked in by mwhitworth, 3 years ago)

Add cmdLine field, as we now keep a copy of the command line.

Line 
1/*  This file is part of Whitix.
2 *
3 *  Whitix is free software; you can redistribute it and/or modify
4 *  it under the terms of the GNU General Public License as published by
5 *  the Free Software Foundation; either version 2 of the License, or
6 *  (at your option) any later version.
7 *
8 *  Whitix is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *  GNU General Public License for more details.
12 *
13 *  You should have received a copy of the GNU General Public License
14 *  along with Whitix; if not, write to the Free Software
15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16 *
17 */
18
19#ifndef TASK_H
20#define TASK_H
21
22#include <llist.h>
23#include <typedefs.h>
24#include <i386/virtual.h>
25#include <i386/i386.h>
26#include <wait.h>
27
28struct Process;
29struct JournalHandle;
30
31#define THR_USED_MATH 1
32#define THR_NEED_RESCHED        2       /* TODO: Use in preemption. */
33
34struct Thread
35{
36        volatile DWORD currStack;
37        struct Process* parent;
38        struct Context* currContext;
39        DWORD state,entry,esp3;
40        struct ListHead list;
41        int quantums, flags, priority, id;
42        int preemptCount;
43        int refs; /* Used by waitqueues and ThrFreeProcess really, otherwise WakeUp ends up waking a thread that doesn't exist */
44        union FpuSave fpuData;
45        unsigned long tlsGdt[2]; /* for the GDT */
46        struct JournalHandle* currHandle; /* Each thread can run its own transaction. */
47};
48
49/* FIXME: Move soon. */
50inline static void TlsInstall(struct Thread* thread)
51{
52        extern unsigned char* gdt;
53       
54        memcpy((((unsigned char*)&gdt)+GDT_TLS_OFFSET), thread->tlsGdt, sizeof(unsigned long)*2);
55}
56
57
58
59#define ThrGetThread(thread)            ((thread)->refs++)
60#define ThrReleaseThread(thread) \
61do { (thread)->refs--;  if ((thread)->refs <= 0) ThrFreeThread((thread)); } while(0)
62
63extern struct Thread* idleTask;
64
65/* Thread defines go here */
66
67#define THR_RUNNING 1
68#define THR_PAUSED  2
69#define THR_DYING   4
70
71struct Process
72{
73        struct ListHead next,sibling,children;
74        int exitCode, state;
75
76        /* File table */
77        struct File** files; /* Dynamically allocated */
78        Spinlock fileListLock;
79        int numFds;
80
81        /* Filesytem context. */
82        struct VNode *cwd,*root,*exec;
83
84        char* name;
85        WaitQueue waitQueue;
86        char* sCwd; /* Allocated dynamically, size is PATH_MAX */
87        DWORD pid;
88        int cId;
89        struct KeObject object;
90        struct ListHead areaList;
91        struct MemManager* memManager;
92        struct Process* parent;
93       
94        /* Copy of the command line. */
95        char* cmdLine;
96};
97
98#define ThrGetProcess(process) (KeObjGet(&process->object))
99#define ThrPutProcess(process) (KeObjPut(&process->object))
100
101#endif
Note: See TracBrowser for help on using the browser.