Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So I have the following header file: #if defined(DEBUG) #define DPRINTF(fmt, args...) printf(DEBUG: %s:%d:%s(): fmt, __FILE__, __LINE__, __func__, ##args) #else #define DPRINTF(fmt, args...)

So I have the following header file:

#if defined(DEBUG) #define DPRINTF(fmt, args...) printf("DEBUG: %s:%d:%s(): " fmt, \ __FILE__, __LINE__, __func__, ##args) #else #define DPRINTF(fmt, args...) /* do nothing if not defined*/ #endif

#define MOUSE_EVENT_DEV "/dev/input/event1"

#define NUM_EVENTS 2 #define NUM_MUTEXES 3 #define NUM_THREADS 5 #define TOTAL_TIME 2000 #define TRUE 1 #define FALSE 0

struct Tasks { int task_type; // Periodic or aperiodic task int task_num; int event_key; // Event number to poll on int priority; int period; // Period of periodic task int loop_iter[3]; // loop iterations for computation int mutex_num; };

#define THREAD0 {0, 0, 0, 90, 10, {500000, 200000, 50000}, 2} #define THREAD1 {0, 1, 0, 91, 28, {500000, 200000, 50000}, 1} #define THREAD2 {0, 2, 0, 92, 64, {500000, 200000, 50000}, 2} #define THREAD3 {1, 3, 0, 93, 10, {500000, 200000, 50000}, 2} #define THREAD4 {1, 4, 1, 94, 10, {500000, 200000, 50000}, 0}

struct Tasks threads[NUM_THREADS]={THREAD0, THREAD1, THREAD2, THREAD3, THREAD4};

I need to develop a program that uses POSIX threads to implement these task models on Linux environment. The task body is defined as the following sequence:

where lock_m and unlock_m are locking and unlocking operations on mutex m, and compute_n indicates a local computation. To simulate a local computation, we will use a busy loop of x iterations.

My biggest confusion is how to point at those variables in the header file. For example, If I wanted:

Int TEST = task_type in THREAD0

How would I achieve that? I have been stuck on this for a while or is their a way to copy struct over, I cannot edit the header file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

Students also viewed these Databases questions

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago