works no files

This commit is contained in:
2025-12-10 14:23:02 +07:00
parent 2b488e06eb
commit 43b29e59e7
3 changed files with 439 additions and 0 deletions

61
lab_6/Makefile Normal file
View File

@@ -0,0 +1,61 @@
CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -g
LDFLAGS_IPC = -lrt -pthread
# SHM/SEM args: <shm_name> <sem_client_name> <sem_server_name> [iterations]
SHM_NAME = /myshm
SEM_CLIENT_NAME = /sem_client
SEM_SERVER_NAME = /sem_server
SERVER_ITERS = 3
all: shm
# ===== POSIX SHM + SEM targets =====
shm: server client
server: server.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_IPC)
client: client.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_IPC)
# ===== Tests =====
test_server: shm
@echo "=== Запуск сервера POSIX SHM+SEM ==="
@echo "В другом терминале выполните: make test_clients"
./server $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) $(SERVER_ITERS)
test_clients: shm
@echo "=== Запуск нескольких клиентов ==="
echo "abacaba" | ./client $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) & \
echo "xxxxxx" | ./client $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) & \
echo "hello world" | ./client $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) & \
wait
# Автотест: сервер в фоне, несколько клиентов
test_all: shm
@echo "=== Автотест POSIX SHM+SEM ==="
./server $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) $(SERVER_ITERS) & \
SRV=$$!; \
sleep 1; \
echo "abacaba" | ./client $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) & \
echo "kekekek" | ./client $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) & \
echo "foobar" | ./client $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) & \
wait; \
wait $$SRV
# Очистка
clean:
@echo "Очистка..."
rm -f server client
help:
@echo "Available targets:"
@echo " shm - Build POSIX SHM+SEM programs"
@echo " test_server - Run SHM+SEM server (clients in another terminal)"
@echo " test_clients - Run several client processes"
@echo " test_all - Automatic end-to-end test"
@echo " clean - Remove built files"
@echo " help - Show this help"
.PHONY: all shm test_server test_clients test_all clean help