2 Copyright (C) 2008 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * Process management functions
26 #ifndef KE_PROCESS_H_INCLUDED
27 #define KE_PROCESS_H_INCLUDED
30 #include <planlos/signals.h>
31 #include "mm/memory.h"
37 typedef struct KeProcess
40 * Address space of the process
42 MmAddressSpace memory
;
48 * Array of threads in the process.
50 struct KeThread
**threads
;
56 * Process lock. Has to be locked whenever the process is modified.
61 * If this is set to 1, the process is a zombie process (was closed, but not
67 * Array containing the open file handles. Entries can be 0 if the file was
72 * Number of entries in the fd array.
76 * Current working directory.
81 * Signal handlers for the current process.
83 uintptr_t signal_handlers
[NSIG
];
85 struct KeThread
*waitthread
;
89 * Initialitzes the process system.
91 int keInitProcessManager(void);
94 * Creates a new process, with an empty address space and no threads attached.
96 KeProcess
*keCreateProcess(void);
98 * Stops all threads belonging to a process and stops the process (makes it a
101 int keTerminateProcess(KeProcess
*process
);
103 * Stops all threads belonging to a process and completely destroys the process.
105 int keDestroyProcess(KeProcess
*process
);
107 * Clears the address space of the process and stops all threads in it but the
110 int keClearProcess(KeProcess
*process
, struct KeThread
*current
);
113 * Returns the process with the given ID.
115 KeProcess
*keGetProcess(uint32_t pid
);
118 * Sends a signal to the process.
120 void keSendSignal(KeProcess
*process
, struct KeThread
*thread
, int signal
);