/* config.h
 * PSR 2sem assignment
 * DO NOT MODIFY
 */

#ifndef PSR2SEM_H
#define PSR2SEM_H

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

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

/* getchar, etc. */
#include <stdio.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);

/*
 * CreateTasks()
 *
 *  Entry point function.
 */
void CreateTasks(void);

#endif