-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreadbank.h
34 lines (29 loc) · 1.06 KB
/
threadbank.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
#ifndef THREADBANK_H
#define THREADBANK_H
#include <stdio.h> /* scanf, printf, fgets */
#include <string.h> /* strtok, memset */
#include <stdlib.h> /* atof */
#include <pthread.h> /* pthread_create, pthread_mutex_* */
#include <math.h> /* log10, abs, floor */
#include <fcntl.h> /* fcntl */
#include <signal.h> /* signal, sigaction */
#include <unistd.h>
#include <sys/mman.h> /* mmap */
#include <sys/types.h> /* gettid */
#define INPUT_SIZE 1024
#define READ 0
#define WRITE 1
void sig_handler(int signo); // Handle signals
void master_desk(void); // Master desk function
int main(int argc, char *argv[]); // Main function initializing the bank
int *queue_arr; // Desk specific queues
int *flag; // Flag for reporting the withdrawals and deposits
int n; // Number of desks
int *fd1; // Master to desk, d1[0] to read and fd1[1] to write
int *fd2; // Desk to master
char *request; // Array for requests
pid_t pid_p; // Parent PID
int i;
int deposit_master; // Variable for total deposit count
int withdraw_master; // Variable for total withdrawal count
#endif // THREADBANK_H