Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*lsp sigset()함수 예제 315p~316p*/
- /*ssu_sigset.c*/
- /*20162468 박다은*/
- #include <stdio.h>
- #include <stdlib.h>
- #include <signal.h>
- #include <sys/time.h> //gettimeofday
- int main()
- {
- struct timeval A, B, C; //시간을 비교할 값들
- gettimeofday(&A, NULL);
- //=======================================
- sigset_t set;
- sigemptyset(&set);
- sigaddset(&set, SIGINT); //SIGINT만 1임
- switch(sigismember(&set, SIGINT))
- {
- case 1 :
- printf("SIGINT is included.\n"); //결과
- break;
- case 0 :
- printf("SIGINT is not included.\n");
- break;
- default :
- printf("failed to call sigismember()\n");
- }
- switch(sigismember(&set, SIGSYS))
- {
- case 1 :
- printf("SIGSYS is included.\n");
- break;
- case 0 :
- printf("SIGSYS is not included.\n");//결과
- break;
- default :
- printf("failed to call sigismember()\n");
- }
- //=======================================
- gettimeofday(&B, NULL);
- C.tv_sec = B.tv_sec - A.tv_sec;
- C.tv_usec = B.tv_usec - A.tv_usec;
- if(C.tv_usec < 0){
- C.tv_sec -= 1;
- C.tv_usec += 1000000;
- }
- printf("ROLLCAKE::Running Time : %ld µs\n", C.tv_sec*1000000 + C.tv_usec); //작은 프로그램이므로 마이크로초로 계산
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement