I used the #define command for following code and constants. I defined in the first WORKLOAD_MAX with 4 and second line TASK_COUNT_MAX with 10 and used multiplication of them in the third line.
after a long time debugging, I realized that the correct value does not apply while executing the code, and I have to manually set the value that I do not like it. (like 40 on the fourth commented line)
Someone can help. Thank you
#define WORKLOAD_MAX 4
#define TASK_COUNT_MAX 10
#define READY_LOOP_DEEP TASK_COUNT_MAX*WORKLOAD_MAX
//#define READY_LOOP_DEEP 40
struct workItem // It is a STRUCT to keep the status of task in different stages
{
int task_ID; // Task ID
int workload_ID; // Workload ID
};
// Read from the beginning of the readyQueue
struct workItem readFromReadyQueue()
{
struct workItem witem;
// Picking up from queue head
witem = readyQueue[readyQueueHead];
// Move forward the queue head index in rotation
readyQueueHead = (readyQueueHead + 1) % READY_LOOP_DEEP;
// Reduce the number of queue elements
readyQueueSize--;
#ifdef PRINT_ReadReadyQueue
printf("Task_ID #%d (Workload_ID #%d) read from readyQueue.\n", witem.task_ID , witem.workload_ID);
#endif
return witem;
}