Changeset 0ee224b for libcfa/src/concurrency
- Timestamp:
- Jun 21, 2021, 3:40:00 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 4d865ca7
- Parents:
- 8110bc3
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
r8110bc3 r0ee224b 29 29 #include <sys/mman.h> // mprotect 30 30 #include <sys/resource.h> // getrlimit 31 #include <sys/syscall.h> // __NR_xxx32 31 } 33 32 … … 102 101 extern void __wake_proc(processor *); 103 102 104 #if defined(CFA_HAVE_LINUX_LIBRSEQ)105 // No forward declaration needed106 #define __kernel_rseq_register rseq_register_current_thread107 #define __kernel_rseq_unregister rseq_unregister_current_thread108 #elif defined(CFA_HAVE_LINUX_RSEQ_H)109 void __kernel_raw_rseq_register (void);110 void __kernel_raw_rseq_unregister(void);111 112 #define __kernel_rseq_register __kernel_raw_rseq_register113 #define __kernel_rseq_unregister __kernel_raw_rseq_unregister114 #else115 // No forward declaration needed116 // No initialization needed117 static inline void noop(void) {}118 119 #define __kernel_rseq_register noop120 #define __kernel_rseq_unregister noop121 #endif122 123 103 //----------------------------------------------------------------------------- 124 104 // Kernel storage … … 256 236 register_tls( mainProcessor ); 257 237 258 __kernel_rseq_register();259 260 238 //initialize the global state variables 261 239 __cfaabi_tls.this_processor = mainProcessor; … … 323 301 mainProcessor->local_data = 0p; 324 302 325 __kernel_rseq_unregister();326 327 303 unregister_tls( mainProcessor ); 328 304 … … 376 352 register_tls( proc ); 377 353 378 __kernel_rseq_register();379 380 354 // SKULLDUGGERY: We want to create a context for the processor coroutine 381 355 // which is needed for the 2-step context switch. However, there is no reason … … 416 390 417 391 proc->local_data = 0p; 418 419 __kernel_rseq_unregister();420 392 421 393 unregister_tls( proc ); … … 833 805 } 834 806 #endif 835 836 #if defined(CFA_HAVE_LINUX_LIBRSEQ)837 // No definition needed838 #elif defined(CFA_HAVE_LINUX_RSEQ_H)839 840 #if defined( __x86_64 ) || defined( __i386 )841 #define RSEQ_SIG 0x53053053842 #elif defined( __ARM_ARCH )843 #ifdef __ARMEB__844 #define RSEQ_SIG 0xf3def5e7 /* udf #24035 ; 0x5de3 (ARMv6+) */845 #else846 #define RSEQ_SIG 0xe7f5def3 /* udf #24035 ; 0x5de3 */847 #endif848 #endif849 850 extern void __disable_interrupts_hard();851 extern void __enable_interrupts_hard();852 853 void __kernel_raw_rseq_register (void) {854 /* paranoid */ verify( __cfaabi_rseq.cpu_id == RSEQ_CPU_ID_UNINITIALIZED );855 856 // int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), 0, (sigset_t *)0p, _NSIG / 8);857 int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), 0, RSEQ_SIG);858 if(ret != 0) {859 int e = errno;860 switch(e) {861 case EINVAL: abort("KERNEL ERROR: rseq register invalid argument");862 case ENOSYS: abort("KERNEL ERROR: rseq register no supported");863 case EFAULT: abort("KERNEL ERROR: rseq register with invalid argument");864 case EBUSY : abort("KERNEL ERROR: rseq register already registered");865 case EPERM : abort("KERNEL ERROR: rseq register sig argument on unregistration does not match the signature received on registration");866 default: abort("KERNEL ERROR: rseq register unexpected return %d", e);867 }868 }869 }870 871 void __kernel_raw_rseq_unregister(void) {872 /* paranoid */ verify( __cfaabi_rseq.cpu_id >= 0 );873 874 // int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, (sigset_t *)0p, _NSIG / 8);875 int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, RSEQ_SIG);876 if(ret != 0) {877 int e = errno;878 switch(e) {879 case EINVAL: abort("KERNEL ERROR: rseq unregister invalid argument");880 case ENOSYS: abort("KERNEL ERROR: rseq unregister no supported");881 case EFAULT: abort("KERNEL ERROR: rseq unregister with invalid argument");882 case EBUSY : abort("KERNEL ERROR: rseq unregister already registered");883 case EPERM : abort("KERNEL ERROR: rseq unregister sig argument on unregistration does not match the signature received on registration");884 default: abort("KERNEL ERROR: rseq unregisteunexpected return %d", e);885 }886 }887 }888 #else889 // No definition needed890 #endif -
libcfa/src/concurrency/ready_queue.cfa
r8110bc3 r0ee224b 30 30 #include "math.hfa" 31 31 32 #include <errno.h> 32 33 #include <unistd.h> 34 35 extern "C" { 36 #include <sys/syscall.h> // __NR_xxx 37 } 33 38 34 39 #include "ready_subqueue.hfa" … … 89 94 } 90 95 96 #if defined(CFA_HAVE_LINUX_LIBRSEQ) 97 // No forward declaration needed 98 #define __kernel_rseq_register rseq_register_current_thread 99 #define __kernel_rseq_unregister rseq_unregister_current_thread 100 #elif defined(CFA_HAVE_LINUX_RSEQ_H) 101 void __kernel_raw_rseq_register (void); 102 void __kernel_raw_rseq_unregister(void); 103 104 #define __kernel_rseq_register __kernel_raw_rseq_register 105 #define __kernel_rseq_unregister __kernel_raw_rseq_unregister 106 #else 107 // No forward declaration needed 108 // No initialization needed 109 static inline void noop(void) {} 110 111 #define __kernel_rseq_register noop 112 #define __kernel_rseq_unregister noop 113 #endif 114 91 115 //======================================================================= 92 116 // Cluster wide reader-writer lock … … 111 135 // Lock-Free registering/unregistering of threads 112 136 unsigned register_proc_id( void ) with(*__scheduler_lock) { 137 __kernel_rseq_register(); 138 113 139 __cfadbg_print_safe(ready_queue, "Kernel : Registering proc %p for RW-Lock\n", proc); 114 140 bool * handle = (bool *)&kernelTLS().sched_lock; … … 165 191 166 192 __cfadbg_print_safe(ready_queue, "Kernel : Unregister proc %p\n", proc); 193 194 __kernel_rseq_unregister(); 167 195 } 168 196 … … 848 876 } 849 877 #endif 878 879 880 #if defined(CFA_HAVE_LINUX_LIBRSEQ) 881 // No definition needed 882 #elif defined(CFA_HAVE_LINUX_RSEQ_H) 883 884 #if defined( __x86_64 ) || defined( __i386 ) 885 #define RSEQ_SIG 0x53053053 886 #elif defined( __ARM_ARCH ) 887 #ifdef __ARMEB__ 888 #define RSEQ_SIG 0xf3def5e7 /* udf #24035 ; 0x5de3 (ARMv6+) */ 889 #else 890 #define RSEQ_SIG 0xe7f5def3 /* udf #24035 ; 0x5de3 */ 891 #endif 892 #endif 893 894 extern void __disable_interrupts_hard(); 895 extern void __enable_interrupts_hard(); 896 897 void __kernel_raw_rseq_register (void) { 898 /* paranoid */ verify( __cfaabi_rseq.cpu_id == RSEQ_CPU_ID_UNINITIALIZED ); 899 900 // int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), 0, (sigset_t *)0p, _NSIG / 8); 901 int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), 0, RSEQ_SIG); 902 if(ret != 0) { 903 int e = errno; 904 switch(e) { 905 case EINVAL: abort("KERNEL ERROR: rseq register invalid argument"); 906 case ENOSYS: abort("KERNEL ERROR: rseq register no supported"); 907 case EFAULT: abort("KERNEL ERROR: rseq register with invalid argument"); 908 case EBUSY : abort("KERNEL ERROR: rseq register already registered"); 909 case EPERM : abort("KERNEL ERROR: rseq register sig argument on unregistration does not match the signature received on registration"); 910 default: abort("KERNEL ERROR: rseq register unexpected return %d", e); 911 } 912 } 913 } 914 915 void __kernel_raw_rseq_unregister(void) { 916 /* paranoid */ verify( __cfaabi_rseq.cpu_id >= 0 ); 917 918 // int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, (sigset_t *)0p, _NSIG / 8); 919 int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, RSEQ_SIG); 920 if(ret != 0) { 921 int e = errno; 922 switch(e) { 923 case EINVAL: abort("KERNEL ERROR: rseq unregister invalid argument"); 924 case ENOSYS: abort("KERNEL ERROR: rseq unregister no supported"); 925 case EFAULT: abort("KERNEL ERROR: rseq unregister with invalid argument"); 926 case EBUSY : abort("KERNEL ERROR: rseq unregister already registered"); 927 case EPERM : abort("KERNEL ERROR: rseq unregister sig argument on unregistration does not match the signature received on registration"); 928 default: abort("KERNEL ERROR: rseq unregisteunexpected return %d", e); 929 } 930 } 931 } 932 #else 933 // No definition needed 934 #endif
Note: See TracChangeset
for help on using the changeset viewer.