Changeset 303c94c in mainline
- Timestamp:
- 2006-03-23T21:13:37Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 38ee55b
- Parents:
- a0bb10ef
- Location:
- generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/include/synch/futex.h
ra0bb10ef r303c94c 44 44 45 45 extern void futex_init(void); 46 extern __native sys_futex_sleep (__address uaddr);46 extern __native sys_futex_sleep_timeout(__address uaddr, __u32 usec, int trydown); 47 47 extern __native sys_futex_wakeup(__address uaddr); 48 48 -
generic/src/synch/futex.c
ra0bb10ef r303c94c 30 30 * Kernel backend for futexes. 31 31 * Deallocation of orphaned kernel-side futex structures is not currently implemented. 32 * Timeouting futexes are currently not implemented.33 32 */ 34 33 35 34 #include <synch/futex.h> 36 35 #include <synch/rwlock.h> 36 #include <synch/spinlock.h> 37 37 #include <synch/synch.h> 38 38 #include <mm/frame.h> 39 39 #include <mm/page.h> 40 40 #include <mm/slab.h> 41 #include <proc/thread.h> 41 42 #include <genarch/mm/page_pt.h> 42 43 #include <genarch/mm/page_ht.h> … … 91 92 * 92 93 * @param uaddr Userspace address of the futex counter. 93 * 94 * @return One of ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED. See synch.h. 94 * @param usec If non-zero, number of microseconds this thread is willing to sleep. 95 * @param trydown If usec is zero and trydown is non-zero, conditional operation will be attempted. 96 * 97 * @return One of ESYNCH_TIMEOUT, ESYNCH_OK_ATOMIC and ESYNCH_OK_BLOCKED. See synch.h. 95 98 * If there is no physical mapping for uaddr ENOENT is returned. 96 99 */ 97 __native sys_futex_sleep (__address uaddr)100 __native sys_futex_sleep_timeout(__address uaddr, __u32 usec, int trydown) 98 101 { 99 102 futex_t *futex; … … 101 104 link_t *item; 102 105 pte_t *t; 103 106 ipl_t ipl; 107 108 ipl = interrupts_disable(); 109 104 110 /* 105 111 * Find physical address of futex counter. … … 109 115 if (!t || !PTE_VALID(t) || !PTE_PRESENT(t)) { 110 116 page_table_unlock(AS, true); 117 interrupts_restore(ipl); 111 118 return (__native) ENOENT; 112 119 } … … 114 121 page_table_unlock(AS, true); 115 122 123 interrupts_restore(ipl); 124 116 125 /* 117 126 * Find the respective futex structure … … 149 158 } 150 159 151 return (__native) waitq_sleep (&futex->wq);160 return (__native) waitq_sleep_timeout(&futex->wq, usec, trydown); 152 161 } 153 162 … … 165 174 link_t *item; 166 175 pte_t *t; 176 ipl_t ipl; 177 178 ipl = interrupts_disable(); 167 179 168 180 /* … … 173 185 if (!t || !PTE_VALID(t) || !PTE_PRESENT(t)) { 174 186 page_table_unlock(AS, true); 187 interrupts_restore(ipl); 175 188 return (__native) ENOENT; 176 189 } … … 178 191 page_table_unlock(AS, true); 179 192 193 interrupts_restore(ipl); 194 180 195 /* 181 196 * Find the respective futex structure. … … 187 202 } 188 203 rwlock_read_unlock(&futex_ht_lock); 189 204 190 205 if (!futex) 191 206 return (__native) ENOENT;
Note:
See TracChangeset
for help on using the changeset viewer.