The struct process
The skeleton definition of struct process is copied below for your convenience.
/* The process control block for a given process. Since
there can be multiple threads per process, we need a separate
PCB from the TCB. All TCBs in a process will have a pointer
to the PCB, and the PCB will have a pointer to the main thread
of the process, which is `special`. */
struct process {
/* Owned by process.c. */
uint32_t* pagedir; /* Page directory. */
char process_name[16]; /* Name of the main thread */
struct thread* main_thread; /* Pointer to main thread */
/* more data members have to be added as needed */
/* ... */
};
You will have to add more data members to this data structure while working on the project tasks. Each process has it’s own copy of a PCB associated with it and all threads in this process have to refer to it. You can access it though the pointer to the struct thread
as follows:
struct thread* t = thread_current();
struct process* pcb = t->pcb;
printf("The name of the current process: %s", pcb->process_name);