Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Napisać program obsługujący sygnały czasu rzeczywistego
- * minimum to:
- * Wyświetlenie komunikatu: "dostałem sygnał taki i taki"
- * Dodatkowe wymogi
- * musi umieć odebrać dane przekazane od sygnału
- * musi umieć przetwarzać przynajmniej (ale może też więcej) 2 różne sygnały
- * obsługa sygnału ma być osługą synchroniczną (przynajmniej 3 wątki)
- * (ad1. w tym 1 wątek macierzysty i 2 wątki do obsługi sygnału)
- * napisać własną komende kill która umożliwi wysłanie sygnału z danymi
- *
- * sigfill
- * siempty
- * sigaddset
- * sigdelset
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <pthread.h>
- #include <signal.h>
- int sig1, sig2;
- //SIGFPE
- void* thread1_func(void * arg){
- printf("Read thread 1");
- int sigwait( SIGFPE, &sig1 );
- printf("end read thread 1");
- }
- //SIGINT
- void* thread2_func(void * arg){
- printf("Read thread 2");
- int sigwait( sigsetmask(SIGINT), &sig2 );
- printf("end read thread 2\n");
- }
- int main(void) {
- puts("Starting program");
- pthread_t thread;
- pthread_create( &thread, NULL, &thread1_func, NULL );
- pthread_create( &thread, NULL, &thread2_func, NULL );
- int time = 360;
- for(int i = 0; i < time; i++){
- printf("%d\n",i);
- sleep(1);
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement