This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
sys_prog/midterm/processes/processes.c

44 lines
630 B
C
Raw Normal View History

2019-11-08 08:02:08 +00:00
#include <stdlib.h>
#include "processes.h"
typedef unsigned int uint;
typedef unsigned long int ulong;
const ulong INIT_CAP = 1024;
struct process {
uint pid;
uint ppid;
char user[9];
double priority;
ulong resident_size;
ulong size;
ulong virtual_size;
char command[16];
};
struct processes {
ulong size;
ulong capacity;
struct process procs[];
};
struct processes* new_processes() {
struct processes* p = malloc(sizeof(struct processes) + INIT_CAP *
sizeof(struct process));
if (!p) {
return NULL;
}
p->size = 0;
2019-11-08 08:02:52 +00:00
p->capacity = INIT_CAP;
2019-11-08 08:02:08 +00:00
return p;
}
2019-11-08 08:02:52 +00:00
void delete(struct processes* p) {
free(p);
}
2019-11-08 08:02:08 +00:00