diff options
-rw-r--r-- | include/litmus.h | 2 | ||||
-rw-r--r-- | src/kernel_iface.c | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/include/litmus.h b/include/litmus.h index 7e5092b..2e48e36 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -105,7 +105,7 @@ task_class_t str2class(const char* str); | |||
105 | /* non-preemptive section support */ | 105 | /* non-preemptive section support */ |
106 | void enter_np(void); | 106 | void enter_np(void); |
107 | void exit_np(void); | 107 | void exit_np(void); |
108 | void exit_np_trace(void); | 108 | int exit_np_trace(void); |
109 | int requested_to_preempt(void); | 109 | int requested_to_preempt(void); |
110 | 110 | ||
111 | /* task system support */ | 111 | /* task system support */ |
diff --git a/src/kernel_iface.c b/src/kernel_iface.c index 8ab42de..4ded334 100644 --- a/src/kernel_iface.c +++ b/src/kernel_iface.c | |||
@@ -65,7 +65,9 @@ void enter_np(void) | |||
65 | 65 | ||
66 | void exit_np(void) | 66 | void exit_np(void) |
67 | { | 67 | { |
68 | if (likely(ctrl_page != NULL) && --ctrl_page->sched.np.flag) { | 68 | if (likely(ctrl_page != NULL) && |
69 | ctrl_page->sched.np.flag && | ||
70 | !(--ctrl_page->sched.np.flag)) { | ||
69 | /* became preemptive, let's check for delayed preemptions */ | 71 | /* became preemptive, let's check for delayed preemptions */ |
70 | __sync_synchronize(); | 72 | __sync_synchronize(); |
71 | if (ctrl_page->sched.np.preempt) | 73 | if (ctrl_page->sched.np.preempt) |
@@ -73,15 +75,19 @@ void exit_np(void) | |||
73 | } | 75 | } |
74 | } | 76 | } |
75 | 77 | ||
76 | void exit_np_trace(void) | 78 | int exit_np_trace(void) |
77 | { | 79 | { |
78 | if (likely(ctrl_page != NULL) && --ctrl_page->sched.np.flag) { | 80 | if (likely(ctrl_page != NULL) && |
81 | ctrl_page->sched.np.flag && | ||
82 | !(--ctrl_page->sched.np.flag)) { | ||
79 | __sync_synchronize(); | 83 | __sync_synchronize(); |
80 | if (ctrl_page->sched.np.preempt) { | 84 | if (ctrl_page->sched.np.preempt) { |
81 | ctrl_page->ts_syscall_start = (uint64_t) get_cycles(); | 85 | ctrl_page->ts_syscall_start = (uint64_t) get_cycles(); |
82 | sched_yield(); | 86 | sched_yield(); |
87 | return 1; | ||
83 | } | 88 | } |
84 | } | 89 | } |
90 | return 0; | ||
85 | } | 91 | } |
86 | 92 | ||
87 | int requested_to_preempt(void) | 93 | int requested_to_preempt(void) |