IBNOS
process.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, Michael Müller
3  * Copyright (c) 2014, Sebastian Lackner
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  */
27 
28 #ifndef _H_PROCESS_
29 #define _H_PROCESS_
30 
31 #include <stdint.h>
32 
34 {
35  uint32_t processID;
36 
37  uint32_t pagesPhysical;
38  uint32_t pagesShared;
39  uint32_t pagesNoFork;
40  uint32_t pagesReserved;
41  uint32_t pagesOutpaged;
42 
43  uint32_t handleCount;
46 };
47 
48 #ifdef __KERNEL__
49 
50  struct process;
51 
52  #include <stdbool.h>
53 
54  #include <process/object.h>
55  #include <process/handle.h>
56  #include <memory/physmem.h>
57  #include <memory/paging.h>
58  #include <util/list.h>
59 
60  extern struct linkedList processList;
61 
62  struct process
63  {
64  struct object obj;
65  struct linkedList waiters;
66 
67  /* entry in the processList */
68  struct linkedList entry_list;
69  uint32_t exitcode;
70 
71  /* list of threads associated to this process */
72  struct linkedList threads;
73 
74  /* page directory and page tables (mapped into the kernel) */
76  struct pagingEntry *pageTables[PAGETABLE_COUNT];
77 
78  /* entryPoint of main thread */
79  void *entryPoint;
80 
81  /* program arguments in user space */
83  uint32_t user_programArgumentsLength; /* in pages */
84 
85  /* envirionment variables in user space */
87  uint32_t user_environmentVariablesLength; /* in pages */
88 
89  /* handles */
91  };
92 
93  struct process *processCreate(struct process *original);
94  uint32_t processCount();
95  uint32_t processInfo(struct processInfo *info, uint32_t count);
96 
97 #endif
98 
99 #endif /* _H_PROCESS_ */
#define PAGETABLE_COUNT
Definition: paging.h:38
void * entryPoint
Definition: process.h:79
struct process * processCreate(struct process *original)
Creates a new kernel process object.
Definition: process.c:77
void * user_programArgumentsBase
Definition: process.h:82
uint32_t processCount()
Returns the number of total processes in the system.
Definition: process.c:245
uint32_t numberOfTotalThreads
Definition: process.h:44
struct pagingEntry * pageDirectory
Definition: process.h:75
uint32_t pagesNoFork
Definition: process.h:39
uint32_t pagesOutpaged
Definition: process.h:41
uint32_t processInfo(struct processInfo *info, uint32_t count)
Fills out the processInfo structure with information about each individual process.
Definition: process.c:265
uint32_t pagesReserved
Definition: process.h:40
uint32_t user_environmentVariablesLength
Definition: process.h:87
Definition: object.h:69
uint32_t numberOfBlockedThreads
Definition: process.h:45
struct object ** handles
Definition: handle.h:50
uint32_t pagesShared
Definition: process.h:38
void * user_environmentVariablesBase
Definition: process.h:86
uint32_t user_programArgumentsLength
Definition: process.h:83
uint32_t pagesPhysical
Definition: process.h:37
uint32_t processID
Definition: process.h:35
struct linkedList processList
Definition: process.c:43
uint32_t handleCount
Definition: process.h:43
uint32_t exitcode
Definition: process.h:69