summaryrefslogtreecommitdiff
path: root/main.h
blob: c746d755b98e0292802c73ddcf24c8ae515a3576 (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
#ifndef __IFMO_DISTRIBUTED_CLASS_MAIN__H
#define __IFMO_DISTRIBUTED_CLASS_MAIN__H

#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>

#define MAX_X       ( 10 )
#define MAX_PROCCNT ( MAX_X + 1 )
#define MAX_PIPES   ( MAX_PROCCNT ) * ( MAX_PROCCNT - 1 )

typedef struct {
  int     pipes[MAX_PIPES][2];
  uint8_t proccnt;
  uint8_t x;

  FILE* events_log;
  FILE* pipes_log;
  pid_t parent_pid;
} dist_info_t;

typedef struct {
  int id;
  dist_info_t *dist_info;
} my_info_t;

void close_redundant_pipes( dist_info_t *info, uint8_t id );

#endif // __IFMO_DISTRIBUTED_CLASS_MAIN__H