-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpcb.h
73 lines (56 loc) · 1.87 KB
/
pcb.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
#ifndef _PCB_H
#define _PCB_H
#include "file.h"
#include "filesys_struct.h"
#include "filesys.h"
#include "rtc.h"
#include "term_driver.h"
#include "keyboard.h"
#include "types.h"
#include "lib.h"
#define FILE_ARRAY_SIZE 8
typedef void (*dz_op)(void);
typedef void (*seg_op)(void);
typedef void (*intr_op)(void);
typedef void (*alarm_op)(void);
typedef void (*user1_op)(void);
typedef struct sig_ops {
dz_op div_zero;
seg_op seg_fault;
intr_op interrupt;
alarm_op alarm;
user1_op user;
} sig_ops;
typedef struct pcb {
int32_t pid;
uint32_t ESP; // this is for switching back and forth between terminals
uint32_t EBP;
uint32_t switch_ESP; // used to restore the parent task's stack when halting
uint32_t switch_EBP;
uint32_t program_start; // where the starting point for the program is
/* the file array (Appendix A 7.2) */
struct pcb * parent; // the parent task's pcb pointer
struct pcb * child;
uint8_t arg[FILE_NAME_LENGTH];
sig_ops signal_ops;
uint8_t sig_pending;
uint8_t sig_masked;
file_t file_array[FILE_ARRAY_SIZE];
} pcb_t; //no alignment here as pcb is not 8 kb. Align the task struct which includes the pcb.
/* "not implemented" */
int32_t ni_open(const uint8_t *filename);
int32_t ni_read(int32_t fd, void *buf, int32_t nbytes);
int32_t ni_write(int32_t fd, const void *buf, int32_t nbytes);
int32_t ni_close(int32_t fd);
/* reset all processes, called before first shell execution */
void ready_all_processes();
/* initializes a pcb */
int32_t init_pcb(pcb_t * pcb, pcb_t * parent, int32_t pid, uint32_t start, uint8_t * arg);
/* adds a file to a pcb's file array */
int32_t add_file(pcb_t * pcb, file_t file);
/* closes a file in a pcb's file array */
int32_t close_file(pcb_t * pcb, int32_t fd);
/* unitializes a pcb */
int32_t close_pcb(pcb_t * pcb);
/* helper functions */
#endif