Changeset 5c76cc61 in mainline
- Timestamp:
- 2018-06-19T19:46:03Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3bd1d7d4
- Parents:
- 9f272d9
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-05-31 16:37:35)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-19 19:46:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async/ports.c
r9f272d9 r5c76cc61 60 60 iface_t iface; 61 61 62 /** Futex protecting the hash table */63 futex_t futex;64 65 62 /** Interface ports */ 66 63 hash_table_t port_hash_table; … … 104 101 static void *fallback_port_data = NULL; 105 102 103 /** Futex guarding the interface hash table. */ 104 static futex_t interface_futex = FUTEX_INITIALIZER; 106 105 static hash_table_t interface_hash_table; 107 106 … … 177 176 178 177 interface->iface = iface; 179 futex_initialize(&interface->futex, 1);180 178 interface->port_id_avail = 0; 181 179 … … 188 186 async_port_handler_t handler, void *data) 189 187 { 188 // TODO: Move the malloc out of critical section. 190 189 port_t *port = (port_t *) malloc(sizeof(port_t)); 191 190 if (!port) 192 191 return NULL; 193 192 194 futex_down(&interface->futex);195 196 193 port_id_t id = interface->port_id_avail; 197 194 interface->port_id_avail++; … … 203 200 hash_table_insert(&interface->port_hash_table, &port->link); 204 201 205 futex_up(&interface->futex);206 207 202 return port; 208 203 } … … 213 208 interface_t *interface; 214 209 215 futex_ down(&async_futex);210 futex_lock(&interface_futex); 216 211 217 212 ht_link_t *link = hash_table_find(&interface_hash_table, &iface); … … 222 217 223 218 if (!interface) { 224 futex_u p(&async_futex);219 futex_unlock(&interface_futex); 225 220 return ENOMEM; 226 221 } … … 228 223 port_t *port = async_new_port(interface, handler, data); 229 224 if (!port) { 230 futex_u p(&async_futex);225 futex_unlock(&interface_futex); 231 226 return ENOMEM; 232 227 } … … 234 229 *port_id = port->id; 235 230 236 futex_u p(&async_futex);231 futex_unlock(&interface_futex); 237 232 238 233 return EOK; … … 260 255 port_t *port = NULL; 261 256 262 futex_ down(&async_futex);257 futex_lock(&interface_futex); 263 258 264 259 ht_link_t *link = hash_table_find(&interface_hash_table, &iface); … … 272 267 } 273 268 274 futex_u p(&async_futex);269 futex_unlock(&interface_futex); 275 270 276 271 return port;
Note:
See TracChangeset
for help on using the changeset viewer.