summaryrefslogtreecommitdiff
path: root/shared.h
blob: 30c8ffea4f1c87535150f1f1658937512ba678d9 (plain)
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
#ifndef SHARED_H
#define SHARED_H

#include <pthread.h>

#define MAX_JOBS 100
#define MAX_PATH 256
#define MAX_NODES 4

#define SHM_NAME "/job_queue_shm"
#define SHM_NODE_STATUS "/node_status_shm"

typedef struct {
    pthread_mutex_t mutex;
    char jobs[MAX_JOBS][MAX_PATH];
    int head;
    int tail;
} JobQueue;

typedef struct {
    int node_id;
    int running_jobs;
    float load;  // from /proc/[pid]/stat or getloadavg()
} NodeStatus;

typedef struct {
    pthread_mutex_t mutex;
    NodeStatus statuses[MAX_NODES];
} NodeStatusArray;

#endif