/* company.h
 * PSR 3shm assignment
 * DO NOT MODIFY
 */

#ifndef PSR3SHM_COMPANY_H
#define PSR3SHM_COMPANY_H

/* taskDelay, taskSpawn, etc. */
#include <taskLib.h>

/* semTake, semGive, etc. */
#include <semLib.h>

/* getchar, etc. */
#include <stdio.h>

/* init_shm, etc. */
#include "shm.h"

/* Macro to check commands for errors. */
#define CHECK(cmd) ({ STATUS ret = (cmd); if (ret == ERROR) { perror(#cmd); }; ret; })

/* taskDelay(WORK_TIME) */
#define WORK_TIME 50

/* taskDelay(BREAK_TIME) */
#define BREAK_TIME 50

/* Semaphore used for simulating the repository of shovels. */
extern SEM_ID semShovels;
#define NUM_OF_SHOVELS 3

/* Semaphore used for simulating the soil heap. */
extern SEM_ID semSoilHeap;

/*
 * LowerDigger()
 *  : (int) n -- ID of the worker
 *
 *  This function is spawned on demand as a task with name `tWorkerL%d`.
 */
void LowerDigger(int n);

/*
 * UpperDigger()
 *  : (int) n -- ID of the worker
 *
 *  This function is spawned on demand as a task with name `tWorkerU%d`.
 */
void UpperDigger(int n);

/*
 * main()
 *
 *  Entry point function for the Real Time Process.
 */
int main(int argc, char** argv);

#endif