MDAT  1.0
 All Classes Files Functions Variables Typedefs Pages
CheckerWrapper Class Reference

Checker wrapper. More...

Public Member Functions

void init (CheckerFuncPtr fn)
 Initializes the wrapper. More...
 
void invoke (int id, string section)
 Invoke the checker. More...
 

Detailed Description

Since each problem or program has their own unique synchronization requirements, the checker is external to MDAT. MDAT provides an interface for interacting with a checker via a callback function. The callback function must adhere to the following prototype and restrictions:

const char *checkerCallback(int id, const char *section, const char *property);

Parameters:

  • id: The id of the thread.
  • section: The section that was just entered using mdat_enter_section or a special section (see below).
  • property: The type of thread – will be the same as the property specified when the thread was created using mdat_thread_start.

The function should return NULL if the checker detects no errors and return an error message if an error was detected.

The checker wrapper will call the supplied checker (to init) at the following times:

  • When mdat_enter_section is called. The section is the section that was just entered (the section parameter to mdat_enter_section is passed directly into the checker)
  • When mdat_thread_start is called. The section is the string ThreadStart. This is used to initialize the checker for each thread.
  • When mdat_thread_finish is called. The section is the string ThreadFinish. This is used to alert the checker that a thread has finished.
  • When all of the threads are finished. The section is the string AllFinish. This is used to alert the checker that all threads have finished.

Note: When the last thread finishes, the checker is invoked twice – once with the section ThreadFinish and then once with the section AllFinish. In both cases, the thread id is the id of the last thread to finish.

When designing a checker, it is helpful to separate the functionality of the callback function based on different combinations of the section and the property. For a given section / property pair, the checker may do one or more of the following:

  • Check for a concurrency error.
  • Update checker state.
  • Update checker state and check for a concurrency error.
  • Do nothing (but return NULL).

Member Function Documentation

void CheckerWrapper::init ( CheckerFuncPtr  fn)

Initializes the wrapper.

Parameters
[in]fnchecker function
void CheckerWrapper::invoke ( int  id,
string  section 
)

Call the checker function. The id and section are passed directly into the checker.

Parameters
[in]idthread id
[in]sectionname of section
This is a personal WEB site developed and maintained by an individual and not by Seattle University. The content and link(s) provided on this site do not represent or reflect the view(s) of Seattle University. The individual who authored this site is solely responsible for the site's content. This site and its author are subject to applicable University policies including the Computer Acceptable Use Policy (www.seattleu.edu/policies).