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 6a5be52 was
3373f87,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
Added simple benchmark to measure interrupt delivering cost
|
-
Property mode set to
100644
|
File size:
788 bytes
|
Line | |
---|
1 | #include <pthread.h> |
---|
2 | #include <stdlib.h> |
---|
3 | #include <signal.h> |
---|
4 | |
---|
5 | #define __CFA_SIGCXT__ ucontext_t * |
---|
6 | #define __CFA_SIGPARMS__ __attribute__((unused)) int sig, __attribute__((unused)) siginfo_t *sfp, __attribute__((unused)) __CFA_SIGCXT__ cxt |
---|
7 | |
---|
8 | void sigHandler( __CFA_SIGPARMS__ ) { |
---|
9 | sigset_t mask; |
---|
10 | sigemptyset( &mask ); |
---|
11 | sigaddset( &mask, SIGUSR1 ); |
---|
12 | |
---|
13 | if ( sigprocmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) { |
---|
14 | abort(); |
---|
15 | } // if |
---|
16 | } |
---|
17 | |
---|
18 | int main() { |
---|
19 | |
---|
20 | struct sigaction act; |
---|
21 | |
---|
22 | act.sa_sigaction = (void (*)(int, siginfo_t *, void *))sigHandler; |
---|
23 | sigemptyset( &act.sa_mask ); |
---|
24 | sigaddset( &act.sa_mask, SIGUSR1 ); |
---|
25 | |
---|
26 | act.sa_flags = SA_SIGINFO; |
---|
27 | |
---|
28 | if ( sigaction( SIGUSR1, &act, NULL ) == -1 ) { |
---|
29 | abort(); |
---|
30 | } // if |
---|
31 | |
---|
32 | for( int i = 0; i < 50000000ul; i++ ) { |
---|
33 | pthread_kill( pthread_self(), SIGUSR1 ); |
---|
34 | } |
---|
35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.