-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsum.h
More file actions
57 lines (47 loc) · 1.62 KB
/
sum.h
File metadata and controls
57 lines (47 loc) · 1.62 KB
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
/*
* sum-tool - sum.h - Header file containing macro definitions and data structures for the sum program.
*
* Copyright (C) 2025 Yannick Fenz'l
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef SUM_H
#define SUM_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <semaphore.h>
#define MAX_WORKERS 9
#define MAX_CHUNKSIZE 9999
#define MAX_MSG_SIZE sizeof(struct msg_request)
#define TERMINATION_SIGNAL -1 // Macro for termination signal
#define PERM 0666 // Permissions for message queue, shared memory, and semaphore
#define MQ_NAME "/sum_queue" // Message queue name
#define SHM_NAME "/global_sum" // Shared memory name
#define SEM_NAME "/sem" // Semaphore name
// Message structure for passing requests
struct msg_request {
long start; // Start of the range
long end; // End of the range
};
// Shared memory structure for global sum
struct global_sum {
long total; // Total sum
};
#endif // SUM_H