/* * Project 3 - Shared memory and semaphores. * Dr. Silaghi's Operating System Concepts. * main.c - Main entry point for daemon application. * By Michael Rywalt - 2569 */ /* Necessary include files. */ #include #include "main.h" /* Necessary definitions. */ /******** * main * ******** * * Function: main * * Purpose: Daemon's main entry point. * * Parameters: None for this program. * * Returns: EXIT_OK on success, * EXIT_ERROR on failure. */ int main() { int *pInteger; int iWaitTime = 1; /* 1 second counter. */ /* Initialize he use of semaphores. */ InitSemaphore(); /* Initialize the shared memory. */ pInteger = InitSharedMemory(); /* Start the daemon. */ InitDaemon(pInteger); /* Start the counter. */ Counter(pInteger, iWaitTime); /* We're done, so detatch the shared memory. */ DetatchSharedMemory(pInteger); /* Uninitialize the use of semaphores. */ DestroySemaphore(); /* Exit daemon. */ DestroyDaemon(EXIT_OK); return EXIT_OK; }