thr_kern.c (18415) | thr_kern.c (22315) |
---|---|
1/* 2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 279 unchanged lines hidden (view full) --- 288 * structure: 289 */ 290 pthread->timeout = 1; 291 292 /* 293 * Change the threads state to allow 294 * it to be restarted: 295 */ | 1/* 2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 279 unchanged lines hidden (view full) --- 288 * structure: 289 */ 290 pthread->timeout = 1; 291 292 /* 293 * Change the threads state to allow 294 * it to be restarted: 295 */ |
296 pthread->state = PS_RUNNING; | 296 PTHREAD_NEW_STATE(pthread,PS_RUNNING); |
297 } 298 } 299 } 300 301 /* Check if there is a current thread: */ 302 if (_thread_run != &_thread_kern_thread) { 303 /* 304 * Save the current time as the time that the thread --- 513 unchanged lines hidden (view full) --- 818 819 /* There are no more threads, so exit this process: */ 820 exit(0); 821} 822 823static void 824_thread_signal(pthread_t pthread, int sig) 825{ | 297 } 298 } 299 } 300 301 /* Check if there is a current thread: */ 302 if (_thread_run != &_thread_kern_thread) { 303 /* 304 * Save the current time as the time that the thread --- 513 unchanged lines hidden (view full) --- 818 819 /* There are no more threads, so exit this process: */ 820 exit(0); 821} 822 823static void 824_thread_signal(pthread_t pthread, int sig) 825{ |
826 int done; |
|
826 long l; 827 pthread_t new_pthread; 828 struct sigaction act; 829 void *arg; 830 | 827 long l; 828 pthread_t new_pthread; 829 struct sigaction act; 830 void *arg; 831 |
832 /* 833 * Assume that the signal will not be dealt with according 834 * to the thread state: 835 */ 836 done = 0; 837 |
|
831 /* Process according to thread state: */ 832 switch (pthread->state) { | 838 /* Process according to thread state: */ 839 switch (pthread->state) { |
833 /* States which do not change when a signal is trapped: */ | 840 /* States which do not change when a signal is trapped: */ |
834 case PS_COND_WAIT: 835 case PS_DEAD: 836 case PS_FDLR_WAIT: 837 case PS_FDLW_WAIT: 838 case PS_JOIN: 839 case PS_MUTEX_WAIT: 840 case PS_RUNNING: 841 case PS_STATE_MAX: 842 case PS_SIGTHREAD: 843 case PS_SUSPENDED: 844 /* Nothing to do here. */ 845 break; 846 | 841 case PS_COND_WAIT: 842 case PS_DEAD: 843 case PS_FDLR_WAIT: 844 case PS_FDLW_WAIT: 845 case PS_JOIN: 846 case PS_MUTEX_WAIT: 847 case PS_RUNNING: 848 case PS_STATE_MAX: 849 case PS_SIGTHREAD: 850 case PS_SUSPENDED: 851 /* Nothing to do here. */ 852 break; 853 |
847 /* Wait for child: */ | 854 /* Wait for child: */ |
848 case PS_WAIT_WAIT: 849 /* Check if the signal is from a child exiting: */ 850 if (sig == SIGCHLD) { 851 /* Reset the error: */ 852 _thread_seterrno(pthread, 0); 853 854 /* Change the state of the thread to run: */ | 855 case PS_WAIT_WAIT: 856 /* Check if the signal is from a child exiting: */ 857 if (sig == SIGCHLD) { 858 /* Reset the error: */ 859 _thread_seterrno(pthread, 0); 860 861 /* Change the state of the thread to run: */ |
855 pthread->state = PS_RUNNING; | 862 PTHREAD_NEW_STATE(pthread,PS_RUNNING); |
856 } else { 857 /* Return the 'interrupted' error: */ 858 _thread_seterrno(pthread, EINTR); 859 860 /* Change the state of the thread to run: */ | 863 } else { 864 /* Return the 'interrupted' error: */ 865 _thread_seterrno(pthread, EINTR); 866 867 /* Change the state of the thread to run: */ |
861 pthread->state = PS_RUNNING; | 868 PTHREAD_NEW_STATE(pthread,PS_RUNNING); |
862 } | 869 } |
870 pthread->interrupted = 1; |
|
863 break; 864 | 871 break; 872 |
865 /* 866 * States that are interrupted by the occurrence of a signal 867 * other than the scheduling alarm: 868 */ | 873 /* Waiting on I/O for zero or more file descriptors: */ 874 case PS_SELECT_WAIT: 875 pthread->data.select_data->nfds = -1; 876 877 /* Return the 'interrupted' error: */ 878 _thread_seterrno(pthread, EINTR); 879 pthread->interrupted = 1; 880 881 /* Change the state of the thread to run: */ 882 PTHREAD_NEW_STATE(pthread,PS_RUNNING); 883 break; 884 885 /* 886 * States that are interrupted by the occurrence of a signal 887 * other than the scheduling alarm: 888 */ |
869 case PS_FDR_WAIT: 870 case PS_FDW_WAIT: | 889 case PS_FDR_WAIT: 890 case PS_FDW_WAIT: |
871 case PS_SELECT_WAIT: | |
872 case PS_SLEEP_WAIT: | 891 case PS_SLEEP_WAIT: |
873 case PS_SIGWAIT: | |
874 /* Return the 'interrupted' error: */ 875 _thread_seterrno(pthread, EINTR); | 892 /* Return the 'interrupted' error: */ 893 _thread_seterrno(pthread, EINTR); |
894 pthread->interrupted = 1; |
|
876 877 /* Change the state of the thread to run: */ | 895 896 /* Change the state of the thread to run: */ |
878 pthread->state = PS_RUNNING; | 897 PTHREAD_NEW_STATE(pthread,PS_RUNNING); 898 899 /* Return the signal number: */ 900 pthread->signo = sig; |
879 break; | 901 break; |
902 903 /* Waiting on a signal: */ 904 case PS_SIGWAIT: 905 /* Change the state of the thread to run: */ 906 PTHREAD_NEW_STATE(pthread,PS_RUNNING); 907 908 /* Return the signal number: */ 909 pthread->signo = sig; 910 911 /* Flag the signal as dealt with: */ 912 done = 1; 913 break; |
|
880 } 881 | 914 } 915 |
882 /* Check if this signal is being ignored: */ 883 if (pthread->act[sig - 1].sa_handler == SIG_IGN) { | 916 /* 917 * Check if this signal has been dealt with, or is being 918 * ignored: 919 */ 920 if (done || pthread->act[sig - 1].sa_handler == SIG_IGN) { |
884 /* Ignore the signal for this thread. */ 885 } 886 /* Check if this signal is to use the default handler: */ 887 else if (pthread->act[sig - 1].sa_handler == SIG_DFL) { 888 /* Process according to signal type: */ 889 switch (sig) { | 921 /* Ignore the signal for this thread. */ 922 } 923 /* Check if this signal is to use the default handler: */ 924 else if (pthread->act[sig - 1].sa_handler == SIG_DFL) { 925 /* Process according to signal type: */ 926 switch (sig) { |
890 /* Signals which cause core dumps: */ | 927 /* Signals which cause core dumps: */ |
891 case SIGQUIT: 892 case SIGILL: 893 case SIGTRAP: 894 case SIGABRT: 895 case SIGEMT: 896 case SIGFPE: 897 case SIGBUS: 898 case SIGSEGV: --- 6 unchanged lines hidden (view full) --- 905 906 /* 907 * Do a sigreturn back to where the signal was 908 * detected and a core dump should occur: 909 */ 910 _thread_sys_sigreturn(&pthread->saved_sigcontext); 911 break; 912 | 928 case SIGQUIT: 929 case SIGILL: 930 case SIGTRAP: 931 case SIGABRT: 932 case SIGEMT: 933 case SIGFPE: 934 case SIGBUS: 935 case SIGSEGV: --- 6 unchanged lines hidden (view full) --- 942 943 /* 944 * Do a sigreturn back to where the signal was 945 * detected and a core dump should occur: 946 */ 947 _thread_sys_sigreturn(&pthread->saved_sigcontext); 948 break; 949 |
913 /* Default processing for other signals: */ | 950 /* Default processing for other signals: */ |
914 default: 915 /* 916 * ### Default processing is a problem to resolve! 917 * ### 918 */ 919 break; 920 } 921 } else { --- 56 unchanged lines hidden (view full) --- 978 return; 979} 980 981void 982_thread_kern_sched_state(enum pthread_state state, char *fname, int lineno) 983{ 984 /* Change the state of the current thread: */ 985 _thread_run->state = state; | 951 default: 952 /* 953 * ### Default processing is a problem to resolve! 954 * ### 955 */ 956 break; 957 } 958 } else { --- 56 unchanged lines hidden (view full) --- 1015 return; 1016} 1017 1018void 1019_thread_kern_sched_state(enum pthread_state state, char *fname, int lineno) 1020{ 1021 /* Change the state of the current thread: */ 1022 _thread_run->state = state; |
1023 _thread_run->fname = fname; 1024 _thread_run->lineno = lineno; |
|
986 987 /* Schedule the next thread that is ready: */ 988 _thread_kern_sched(NULL); 989 return; 990} 991 992static void 993_thread_kern_select(int wait_reqd) --- 705 unchanged lines hidden --- | 1025 1026 /* Schedule the next thread that is ready: */ 1027 _thread_kern_sched(NULL); 1028 return; 1029} 1030 1031static void 1032_thread_kern_select(int wait_reqd) --- 705 unchanged lines hidden --- |