Advertisement
Guest User

Untitled

a guest
May 21st, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.22 KB | None | 0 0
  1. /*lsp sigset()함수 예제 315p~316p*/
  2. /*ssu_sigset.c*/
  3. /*20162468 박다은*/
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <signal.h>
  8. #include <sys/time.h> //gettimeofday
  9.  
  10. int main()
  11. {
  12.     struct timeval A, B, C; //시간을 비교할 값들
  13.     gettimeofday(&A, NULL);
  14.     //=======================================
  15.  
  16.     sigset_t set;
  17.  
  18.     sigemptyset(&set);
  19.     sigaddset(&set, SIGINT); //SIGINT만 1임
  20.  
  21.     switch(sigismember(&set, SIGINT))
  22.     {
  23.         case 1 :
  24.             printf("SIGINT is included.\n"); //결과
  25.             break;
  26.         case 0 :
  27.             printf("SIGINT is not included.\n");
  28.             break;
  29.         default :
  30.             printf("failed to call sigismember()\n");
  31.     }
  32.  
  33.     switch(sigismember(&set, SIGSYS))
  34.     {
  35.         case 1 :
  36.             printf("SIGSYS is included.\n");
  37.             break;
  38.         case 0 :
  39.             printf("SIGSYS is not included.\n");//결과
  40.             break;
  41.         default :
  42.             printf("failed to call sigismember()\n");
  43.     }
  44.  
  45.     //=======================================
  46.     gettimeofday(&B, NULL);
  47.  
  48.     C.tv_sec = B.tv_sec - A.tv_sec;
  49.     C.tv_usec = B.tv_usec - A.tv_usec;
  50.     if(C.tv_usec < 0){
  51.         C.tv_sec -= 1;
  52.         C.tv_usec += 1000000;
  53.     }
  54.     printf("ROLLCAKE::Running Time : %ld µs\n", C.tv_sec*1000000 + C.tv_usec); //작은 프로그램이므로 마이크로초로 계산
  55.     exit(0);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement