epoch_test.c (5e68a3dfe30c07337bca284ea65cfe2c4b06d249) | epoch_test.c (70398c2f86e2fbc2120b4a11d9ec9284a6a395f5) |
---|---|
1/*- 2 * Copyright (c) 2018, Matthew Macy <mmacy@freebsd.org> 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 62 unchanged lines hidden (view full) --- 71 startticks = ticks; 72 i = 0; 73 if (eti->threadid & 0x1) 74 mtxp = &mutexA; 75 else 76 mtxp = &mutexB; 77 78 while (i < iterations) { | 1/*- 2 * Copyright (c) 2018, Matthew Macy <mmacy@freebsd.org> 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. --- 62 unchanged lines hidden (view full) --- 71 startticks = ticks; 72 i = 0; 73 if (eti->threadid & 0x1) 74 mtxp = &mutexA; 75 else 76 mtxp = &mutexB; 77 78 while (i < iterations) { |
79 epoch_enter(test_epoch); | 79 epoch_enter_preempt(test_epoch); |
80 mtx_lock(mtxp); 81 i++; 82 mtx_unlock(mtxp); | 80 mtx_lock(mtxp); 81 i++; 82 mtx_unlock(mtxp); |
83 epoch_exit(test_epoch); 84 epoch_wait(test_epoch); | 83 epoch_exit_preempt(test_epoch); 84 epoch_wait_preempt(test_epoch); |
85 } 86 printf("test1: thread: %d took %d ticks to complete %d iterations\n", 87 eti->threadid, ticks - startticks, iterations); 88} 89 90static void 91epoch_testcase2(struct epoch_test_instance *eti) 92{ 93 int i, startticks; 94 struct mtx *mtxp; 95 96 startticks = ticks; 97 i = 0; 98 mtxp = &mutexA; 99 100 while (i < iterations) { | 85 } 86 printf("test1: thread: %d took %d ticks to complete %d iterations\n", 87 eti->threadid, ticks - startticks, iterations); 88} 89 90static void 91epoch_testcase2(struct epoch_test_instance *eti) 92{ 93 int i, startticks; 94 struct mtx *mtxp; 95 96 startticks = ticks; 97 i = 0; 98 mtxp = &mutexA; 99 100 while (i < iterations) { |
101 epoch_enter(test_epoch); | 101 epoch_enter_preempt(test_epoch); |
102 mtx_lock(mtxp); 103 DELAY(1); 104 i++; 105 mtx_unlock(mtxp); | 102 mtx_lock(mtxp); 103 DELAY(1); 104 i++; 105 mtx_unlock(mtxp); |
106 epoch_exit(test_epoch); 107 epoch_wait(test_epoch); | 106 epoch_exit_preempt(test_epoch); 107 epoch_wait_preempt(test_epoch); |
108 } 109 printf("test2: thread: %d took %d ticks to complete %d iterations\n", 110 eti->threadid, ticks - startticks, iterations); 111} 112 113static void 114testloop(void *arg) { 115 --- 18 unchanged lines hidden (view full) --- 134 135static int 136test_modinit(void) 137{ 138 struct thread *td; 139 int i, error, pri_range, pri_off; 140 141 pri_range = PRI_MIN_TIMESHARE - PRI_MIN_REALTIME; | 108 } 109 printf("test2: thread: %d took %d ticks to complete %d iterations\n", 110 eti->threadid, ticks - startticks, iterations); 111} 112 113static void 114testloop(void *arg) { 115 --- 18 unchanged lines hidden (view full) --- 134 135static int 136test_modinit(void) 137{ 138 struct thread *td; 139 int i, error, pri_range, pri_off; 140 141 pri_range = PRI_MIN_TIMESHARE - PRI_MIN_REALTIME; |
142 test_epoch = epoch_alloc(0); | 142 test_epoch = epoch_alloc(EPOCH_PREEMPT); |
143 for (i = 0; i < mp_ncpus*2; i++) { 144 etilist[i].threadid = i; 145 error = kthread_add(testloop, &etilist[i], NULL, &testthreads[i], 146 0, 0, "epoch_test_%d", i); 147 if (error) { 148 printf("%s: kthread_add(epoch_test): error %d", __func__, 149 error); 150 } else { --- 72 unchanged lines hidden --- | 143 for (i = 0; i < mp_ncpus*2; i++) { 144 etilist[i].threadid = i; 145 error = kthread_add(testloop, &etilist[i], NULL, &testthreads[i], 146 0, 0, "epoch_test_%d", i); 147 if (error) { 148 printf("%s: kthread_add(epoch_test): error %d", __func__, 149 error); 150 } else { --- 72 unchanged lines hidden --- |