Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

check_counter.c File Reference

#include <limits.h>
#include "gwlib/gwlib.h"

Include dependency graph for check_counter.c:

Include dependency graph

Go to the source code of this file.

Defines

#define THREADS   16
#define PER_THREAD   (1000)

Functions

void check (void *arg)
int main (void)


Define Documentation

#define PER_THREAD   (1000)
 

Definition at line 71 of file check_counter.c.

#define THREADS   16
 

Definition at line 67 of file check_counter.c.


Function Documentation

void check void *  arg  )  [static]
 

Definition at line 76 of file check_counter.c.

References counter_increase(), and panic.

Referenced by main().

00076                              {
00077     Counter *c;
00078     long i, this, prev;
00079     
00080     c = arg;
00081     prev = -1;
00082     for (i = 0; i < PER_THREAD; ++i) {
00083         this = counter_increase(c);
00084         if (this < 0)
00085             panic(0, "counter returned negative");
00086         if (this < prev)
00087             panic(0, "counter returned smaller than previous");
00088         prev = this;
00089     }
00090 }

Here is the call graph for this function:

int main void   ) 
 

Definition at line 93 of file check_counter.c.

References check(), counter_create(), GW_INFO, gwlib_init(), gwthread_create, gwthread_join(), log_set_output_level(), and threads.

00093                {
00094     Counter *c;
00095     long threads[THREADS];
00096     long i;
00097     
00098     gwlib_init();
00099     log_set_output_level(GW_INFO);
00100     c = counter_create();
00101     for (i = 0; i < THREADS; ++i)
00102         threads[i] = gwthread_create(check, c);
00103     for (i = 0; i < THREADS; ++i)
00104         gwthread_join(threads[i]);
00105     
00106     return 0;
00107 }

Here is the call graph for this function:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.