ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 2c39855 was
2c39855,
checked in by Thierry Delisle <tdelisle@…>, 6 years ago
|
Added tool to generate cpu load
|
-
Property mode set to
100644
|
File size:
924 bytes
|
Rev | Line | |
---|
[2c39855] | 1 | #include <stdbool.h> |
---|
| 2 | #include <stdlib.h> |
---|
| 3 | #include <pthread.h> |
---|
| 4 | |
---|
| 5 | struct S { |
---|
| 6 | int i, j, k, l, m, n; |
---|
| 7 | }; |
---|
| 8 | |
---|
| 9 | void * CallingMalloc( void * arg __attribute__((unused)) ) { |
---|
| 10 | for ( volatile int i = 0; i < 10000; i += 1 ) { |
---|
| 11 | volatile int * ip = (volatile int *)malloc( sizeof( int ) * 1 ); |
---|
| 12 | volatile int * aip = (volatile int *)malloc( sizeof( int ) * 100 ); |
---|
| 13 | volatile struct S * sp = (volatile struct S *)malloc( sizeof(struct S) * 200 ); |
---|
| 14 | |
---|
| 15 | sp->i = 0; |
---|
| 16 | sp->j = 1; |
---|
| 17 | sp->k = 2; |
---|
| 18 | sp->l = 3; |
---|
| 19 | sp->m = 4; |
---|
| 20 | sp->n = 5; |
---|
| 21 | for(int j = 0; j < 100; j++) { |
---|
| 22 | aip[j] = j; |
---|
| 23 | } |
---|
| 24 | *ip = i; |
---|
| 25 | |
---|
| 26 | free( (void*)sp ); |
---|
| 27 | free( (void*)aip ); |
---|
| 28 | free( (void*)ip ); |
---|
| 29 | } |
---|
| 30 | return NULL; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | int main() { |
---|
| 34 | while(true) { |
---|
| 35 | pthread_t t[15]; |
---|
| 36 | for(int i = 0; i < 15; i++) { |
---|
| 37 | pthread_create( &t[i], NULL, CallingMalloc, NULL ); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | for(int i = 0; i < 15; i++) { |
---|
| 41 | pthread_join( t[i], NULL ); |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.