1 /* synchro_crashtest -- tries to crash the logging mecanism by doing // logs*/
3 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include "xbt/synchro.h"
12 XBT_LOG_NEW_DEFAULT_CATEGORY(synchro_crashtest, "Logs of this example");
15 int test_amount = 99; /* Up to 999 to not break the logs (and thus the testing mecanism) */
16 int crasher_amount = 99; /* Up to 99 to not break the logs (and thus the testing mecanism) */
17 int *id; /* to pass a pointer to the threads without race condition */
19 int more_info = 0; /* SET IT TO TRUE TO GET MORE INFO */
21 /* Code ran by each thread */
22 static void crasher_thread(void *arg)
24 int id = *(int *) arg;
27 for (i = 0; i < test_amount; i++) {
29 XBT_INFO("%03d (%02d|%02d|%02d|%02d|%02d|%02d|%02d|%02d|%02d)",
30 test_amount - i, id, id, id, id, id, id, id, id, id);
32 XBT_INFO("XXX (XX|XX|XX|XX|XX|XX|XX|XX|XX)");
36 int crasher(int argc, char *argv[]);
37 int crasher(int argc, char *argv[])
40 xbt_thread_t *crashers;
42 gras_init(&argc, argv);
44 /* initializations of the philosopher mecanisms */
45 id = xbt_new0(int, crasher_amount);
46 crashers = xbt_new(xbt_thread_t, crasher_amount);
48 for (i = 0; i < crasher_amount; i++)
52 for (i = 0; i < crasher_amount; i++) {
53 char *name = bprintf("thread %d", i);
55 xbt_thread_create(name, &crasher_thread, &id[i], 1 /* joinable */ );
60 for (i = 0; i < crasher_amount; i++)
61 xbt_thread_join(crashers[i]);
70 int main(int argc, char *argv[])
74 errcode = crasher(argc, argv);