-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathprocess.h
90 lines (69 loc) · 2.41 KB
/
process.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// ***************************************************************
// process.h - Creation date: 10/04/2022
// -------------------------------------------------------------
// NanoShell Copyright (C) 2022-2023 - Licensed under GPL V3
//
// ***************************************************************
// Programmer(s): iProgramInCpp ([email protected])
// ***************************************************************
#ifndef _PROCESS_H
#define _PROCESS_H
#include<main.h>
#include<memory.h>
#include<task.h>
#include<string.h>
#include<rt.h>
/**************************************************************
A Process is a task or set of tasks that are part of
a running program, the "Process". All tasks that inherit
from the process have the same memory space (i.e. the
Heap). When a task inside a process crashes, ALL tasks
are taken down, and the tasks' heap is deleted.
The Heap APIs are thusly not recommended for use outside
of here anymore.
The Process structures will not be used for any scheduling/
multitasking, only the Task ones will, but these group the
tasks.
***************************************************************/
struct Proc;
#define C_MAX_PROCESS (64)
typedef void (*DeathProc) (struct Proc*);
struct Proc
{
bool bActive;
bool bWillDie;
bool bAttached;
char sIdentifier[250];
int nTasks;
int nTaskCapacity;
Task**sTasks;
void* pDetail;
DeathProc OnDeath;
UserHeap* pHeap;
uint64_t nIdentifier;
void* pSymTab, *pStrTab;
int nSymTabEntries;
bool bWaitingForCrashAck;
ProgramInfo pProgInfo;
ResourceTable sResourceTable;
int nWindows; // Number of windows spawned by this process.
};
typedef struct Proc Process;
enum
{
EX_PROC_SUCCESS,
EX_PROC_TOO_MANY_PROCESSES=0x50000000,
EX_PROC_CANT_MAKE_HEAP,
};
void ExKillProcess(Process *pProc);
void ExProcessDebugDump();
bool ExAddThreadToProcess(Process *pProc, Task* pTask);
void ExJoinProcess(Process *pProc);
void ExDetachProcess(Process *pProc);
Process* ExGetRunningProc();
Process* ExGetProcessByRID(uint64_t rid);
Process* ExCreateProcess (TaskedFunction pTaskedFunc, int nParameter, const char *pIdent, int nHeapSize, int *pErrCode, void* pDetail);
void ExSetProgramInfo(const ProgramInfo* pProgInfo);
bool ExLoadResourceTable(void *pResourceTableData);
Resource* ExLookUpResource(int id);
#endif//_PROCESS_H