1
/************************************************************************
2
The test module for the thread management of Innobase
6
Created 10/5/1995 Heikki Tuuri
7
*************************************************************************/
9
#include "../thr0loc.h"
10
#include "sync0sync.h"
12
#include "os0thread.h"
19
/******************************************************************
20
Thread start function in test1. */
33
printf("Thread %lu starts\n", n);
35
thr_local_set_slot_no(os_thread_get_curr_id(), n);
37
ut_a(n == thr_local_get_slot_no(os_thread_get_curr_id()));
48
/******************************************************************
49
Test function for local storage. */
55
os_thread_t thr1, thr2, thr3, thr4, thr5;
56
os_thread_id_t id1, id2, id3, id4, id5;
58
ulint n1, n2, n3, n4, n5;
60
printf("-------------------------------------------\n");
61
printf("THR-TEST 1. Test of local storage\n");
63
event = os_event_create(NULL);
68
thr1 = os_thread_create(thread1,
72
thr2 = os_thread_create(thread1,
76
thr3 = os_thread_create(thread1,
80
thr4 = os_thread_create(thread1,
84
thr5 = os_thread_create(thread1,
88
os_thread_sleep(500000);
90
ut_a(n1 == thr_local_get_slot_no(id1));
91
ut_a(n2 == thr_local_get_slot_no(id2));
92
ut_a(n3 == thr_local_get_slot_no(id3));
93
ut_a(n4 == thr_local_get_slot_no(id4));
94
ut_a(n5 == thr_local_get_slot_no(id5));
100
os_thread_wait(thr3);
101
os_thread_wait(thr4);
102
os_thread_wait(thr5);
105
printf("Wall clock time for 5 threads %ld milliseconds\n",
109
/************************************************************************
110
Main test function. */
129
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
130
printf("TESTS COMPLETED SUCCESSFULLY!\n");