1 /* synchro_crashtest -- tries to crash the logging mecanism by doing // logs*/
3 /* Copyright (c) 2007-2012. 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. */
11 XBT_LOG_NEW_DEFAULT_CATEGORY(synchro_crashtest, "Logs of this example");
14 int test_amount = 99; /* Up to 999 to not break the logs (and thus the testing mecanism) */
15 int crasher_amount = 99; /* Up to 99 to not break the logs (and thus the testing mecanism) */
16 int *id; /* to pass a pointer to the threads without race condition */
18 int more_info = 0; /* SET IT TO TRUE TO GET MORE INFO */
20 /* Code ran by each thread */
21 static void* crasher_thread(void *arg)
23 int id = *(int *) arg;
26 for (i = 0; i < test_amount; i++) {
28 XBT_INFO("%03d (%02d|%02d|%02d|%02d|%02d|%02d|%02d|%02d|%02d)",
29 test_amount - i, id, id, id, id, id, id, id, id, id);
31 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_os_thread_t *crashers;
42 xbt_init(&argc, argv);
44 /* initializations of the philosopher mecanisms */
45 id = xbt_new0(int, crasher_amount);
46 crashers = xbt_new(xbt_os_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_os_thread_create(name, &crasher_thread, &id[i], NULL );
60 for (i = 0; i < crasher_amount; i++)
61 xbt_os_thread_join(crashers[i],NULL);
69 int main(int argc, char *argv[])
71 return crasher(argc, argv);