kirill-refactor

This commit is contained in:
2025-12-10 16:50:28 +07:00
parent cb9d0ac607
commit f3a5c1f658
114 changed files with 2066 additions and 0 deletions

60
mine/lab_5/Makefile Normal file
View File

@@ -0,0 +1,60 @@
CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -g
LDFLAGS_MQ = -lrt
# SERVER_ARGS: <total_honey> <portion> <period_ms> <starvation_ms>
# WORKER_ARGS: <honey_portion>
SERVER_ARGS = 1000 15 500 500
WORKER_ARGS = 7
all: msg
# ===== POSIX MQ targets =====
msg: msg_server msg_worker
msg_server: server.c common.h
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_MQ)
msg_worker: worker.c common.h
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_MQ)
# ===== Tests =====
test_msg_server: msg
@echo "=== Запуск сервера POSIX MQ ==="
@echo "В другом терминале выполните: make test_msg_workers"
./msg_server $(SERVER_ARGS)
test_msg_workers: msg
@echo "=== Запуск нескольких пчёл ==="
./msg_worker 7 & \
./msg_worker 9 & \
./msg_worker 5 & \
wait
# Автотест: сервер в фоне, несколько пчёл
test_all: msg
@echo "=== Автотест POSIX MQ ==="
./msg_server $(SERVER_ARGS) & \
SRV=$$!; \
sleep 2; \
./msg_worker $(WORKER_ARGS) & \
./msg_worker $(WORKER_ARGS) & \
./msg_worker $(WORKER_ARGS) & \
wait; \
wait $$SRV
# Очистка
clean:
@echo "Очистка..."
rm -f msg_server msg_worker
help:
@echo "Available targets:"
@echo " msg - Build POSIX message queue programs"
@echo " test_msg_server - Run MQ server (use workers in another terminal)"
@echo " test_msg_workers - Run several worker processes"
@echo " test_all - Automatic end-to-end test"
@echo " clean - Remove built files"
@echo " help - Show this help"
.PHONY: all msg test_msg_server test_msg_workers test_all clean help