XenevaOS
Loading...
Searching...
No Matches
Macros | Functions | Variables
process.c File Reference
#include <process.h>
#include <aucon.h>
#include <Mm/vmmngr.h>
#include <Mm/kmalloc.h>
#include <clean.h>
#include <Mm/pmmngr.h>
#include <string.h>
#include <_null.h>
#include <Hal/AA64/sched.h>
#include <Hal/AA64/aa64lowlevel.h>
#include <Mm/shm.h>
#include <loader.h>
#include <Ipc/postbox.h>
#include <Drivers/uart.h>
#include <timer.h>
#include <Cap/capability.h>
#include <Fs/Dev/devfs.h>
#include <Sound/sound.h>
Include dependency graph for process.c:

Macros

#define USER_STACK_FLAG   (1ULL << 54 | 2ULL << 6 | 1ULL << 10 | PTE_NORMAL_MEM | 1)
 
#define USER_STACK   0x000000A000000000
 
#define USER_STACK   0x000000A000000000
 

Functions

void AuAddProcess (AuProcess *parent, AuProcess *proc)
 AuAddProcess – adds process to kernel data structure.
 
void AuRemoveProcess (AuProcess *parent, AuProcess *proc)
 AuRemoveProcess – removes a process from the process data structure.
 
AuProcess * AuProcessFindByPID (AuProcess *proc, int pid)
 AuProcessFindByPID – finds a process by its pid.
 
AuProcess * AuProcessFindByThread (AuProcess *proc, AA64Thread *thread)
 AuProcessFindByThread – finds a process by its main thread.
 
AuProcess * AuProcessFindPID (int pid)
 AuProcessFindPID – finds a process by its pid from the process tree.
 
AuProcess * AuProcessFindThread (AA64Thread *thread)
 AuProcessFindThread – finds a process by its main thread.
 
AuProcess * AuProcessFindSubThread (AA64Thread *thread)
 AuProcessFindSubThread – find a process from its sub threads which contain a pointer to its process slot.
 
int AuAllocateProcessID ()
 AuAllocateProcessID – allocates a new pid and return.
 
uint64_t * CreateUserStack (AuProcess *proc, uint64_t *cr3)
 CreateUserStack – creates new user stack.
 
uint64_t * CreateSubUserStack (AuProcess *proc, uint64_t *cr3)
 CreateSubUserStack – creates new user stack.
 
AuProcess * AuCreateProcessSlot (AuProcess *parent, char *name)
 AuCreateProcessSlot – creates a blank process slot.
 
int AuProcessGetFileDesc (AuProcess *proc)
 AuProcessGetFileDesc – returns a empty file descriptor from process slot, 0, 1 & 2 are reserved for terminal output.
 
int AuCreateUserthread (AuProcess *proc, void(*entry)(), char *name, uint64_t arg)
 Creates a user mode thread.
 
void AuProcessFreeKeResource (AA64Thread *thr)
 AuProcessFreeKeResource – free up allocated kernel resources.
 
void AuProcessWakeWaiters (AuProcess *proc)
 
void AuProcessExit (AuProcess *proc, bool schedulable)
 AuProcessExit – release resources and queue a process for reaping.
 
bool AuProcessCanReap (AuProcess *proc)
 
AuProcess * AuGetKillableProcess (void)
 AuGetKillableProcess – return the first process safe to reap.
 
int AuProcessWaitForTermination (AuProcess *proc, int pid)
 AuProcessWaitForTermination – waits for termination of child processes.
 
int AuProcGetNumProcessCount ()
 AuProcGetNumProcessCount – returns the total number of process created.
 
int AuProcessFetch (AuProcessList *list, int num_proc_count)
 AuProcessFetch – fetch current process table status.
 
void AuProcessReapWaitcount (AuProcess *proc, int num_count)
 AuProcessReapWaitCount – decrease waiting thread counts.
 

Variables

AuProcess * proc_first
 
AuProcess * proc_last
 
AuProcess * root_proc
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2025, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ USER_STACK [1/2]

#define USER_STACK   0x000000A000000000

◆ USER_STACK [2/2]

#define USER_STACK   0x000000A000000000

◆ USER_STACK_FLAG

#define USER_STACK_FLAG   (1ULL << 54 | 2ULL << 6 | 1ULL << 10 | PTE_NORMAL_MEM | 1)

Function Documentation

◆ AuAddProcess()

void AuAddProcess ( AuProcess *  parent,
AuProcess *  proc 
)

AuAddProcess – adds process to kernel data structure.

Parameters
root– pointer to the root process
proc– process to add

◆ AuAllocateProcessID()

int AuAllocateProcessID ( )

AuAllocateProcessID – allocates a new pid and return.

◆ AuCreateProcessSlot()

AuProcess * AuCreateProcessSlot ( AuProcess *  parent,
char *  name 
)

AuCreateProcessSlot – creates a blank process slot.

Parameters
parent– pointer to the parent process

confusing code :hehehehe

just inherit all parent credential's to belong to that uac and group

◆ AuCreateUserthread()

int AuCreateUserthread ( AuProcess *  proc,
void(*)()  entry,
char *  name,
uint64_t  arg 
)

Creates a user mode thread.

Parameters
entry– Entry point address
stack– Stack address
cr3– the top most page map level address
name– name of the thread
priority– (currently unused) thread's priority

◆ AuGetKillableProcess()

AuProcess * AuGetKillableProcess ( void  )

AuGetKillableProcess – return the first process safe to reap.

◆ AuProcessCanReap()

bool AuProcessCanReap ( AuProcess *  proc)

◆ AuProcessExit()

void AuProcessExit ( AuProcess *  proc,
bool  schedulable 
)

AuProcessExit – release resources and queue a process for reaping.

Parameters
proc– process to exit
schedulable– retained for the shared process API; the caller schedules

◆ AuProcessFetch()

int AuProcessFetch ( AuProcessList *  list,
int  num_proc_count 
)

AuProcessFetch – fetch current process table status.

Parameters
list– Pointer to AuProcessList
num_proc_count– number of process count

◆ AuProcessFindByPID()

AuProcess * AuProcessFindByPID ( AuProcess *  proc,
int  pid 
)

AuProcessFindByPID – finds a process by its pid.

Parameters
parent– parent process to search in
pid– process id to find

◆ AuProcessFindByThread()

AuProcess * AuProcessFindByThread ( AuProcess *  proc,
AA64Thread *  thread 
)

AuProcessFindByThread – finds a process by its main thread.

Parameters
parent– parent process to search in
thread– thread to find

◆ AuProcessFindPID()

AuProcess * AuProcessFindPID ( int  pid)

AuProcessFindPID – finds a process by its pid from the process tree.

Parameters
pid– process id of the process

◆ AuProcessFindSubThread()

AuProcess * AuProcessFindSubThread ( AA64Thread *  thread)

AuProcessFindSubThread – find a process from its sub threads which contain a pointer to its process slot.

Parameters
thread– Pointer to sub thread

◆ AuProcessFindThread()

AuProcess * AuProcessFindThread ( AA64Thread *  thread)

AuProcessFindThread – finds a process by its main thread.

Parameters
thread– pointer to main thread

◆ AuProcessFreeKeResource()

void AuProcessFreeKeResource ( AA64Thread *  thr)

AuProcessFreeKeResource – free up allocated kernel resources.

Parameters
thr– Pointer to thread which allocated kernel resources

◆ AuProcessGetFileDesc()

int AuProcessGetFileDesc ( AuProcess *  proc)

AuProcessGetFileDesc – returns a empty file descriptor from process slot, 0, 1 & 2 are reserved for terminal output.

Parameters
proc– pointer to process slot

◆ AuProcessReapWaitcount()

void AuProcessReapWaitcount ( AuProcess *  proc,
int  num_count 
)

AuProcessReapWaitCount – decrease waiting thread counts.

Parameters
proc– desired process
num_count– total number of threads to decrease

◆ AuProcessWaitForTermination()

int AuProcessWaitForTermination ( AuProcess *  proc,
int  pid 
)

AuProcessWaitForTermination – waits for termination of child processes.

Parameters
proc– pointer to process who needs to wait for termination
pid– pid of the process, if -1 then any child process

◆ AuProcessWakeWaiters()

void AuProcessWakeWaiters ( AuProcess *  proc)

◆ AuProcGetNumProcessCount()

int AuProcGetNumProcessCount ( )

AuProcGetNumProcessCount – returns the total number of process created.

◆ AuRemoveProcess()

void AuRemoveProcess ( AuProcess *  parent,
AuProcess *  proc 
)

AuRemoveProcess – removes a process from the process data structure.

Parameters
parent– pointer to the parent process
proc– process to remove

◆ CreateSubUserStack()

uint64_t * CreateSubUserStack ( AuProcess *  proc,
uint64_t *  cr3 
)

CreateSubUserStack – creates new user stack.

Parameters
proc– Pointer to process slot
cr3– pointer to the address space where to map

◆ CreateUserStack()

uint64_t * CreateUserStack ( AuProcess *  proc,
uint64_t *  cr3 
)

CreateUserStack – creates new user stack.

Parameters
proc– Pointer to process slot
cr3– pointer to the address space where to map

Variable Documentation

◆ proc_first

AuProcess* proc_first

◆ proc_last

AuProcess* proc_last

◆ root_proc

AuProcess* root_proc