Changeset 230260ac in mainline for uspace/srv/vfs/vfs_register.c
- Timestamp:
- 2009-06-09T22:27:43Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0e31a2b
- Parents:
- 041186f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_register.c
r041186f r230260ac 46 46 #include <ctype.h> 47 47 #include <bool.h> 48 #include <f utex.h>48 #include <fibril_sync.h> 49 49 #include <adt/list.h> 50 50 #include <as.h> … … 53 53 #include "vfs.h" 54 54 55 atomic_t fs_head_futex = FUTEX_INITIALIZER;55 FIBRIL_MUTEX_INITIALIZE(fs_head_lock); 56 56 link_t fs_head; 57 57 … … 160 160 } 161 161 link_initialize(&fs_info->fs_link); 162 f utex_initialize(&fs_info->phone_futex, 1);162 fibril_mutex_initialize(&fs_info->phone_lock); 163 163 164 164 rc = ipc_data_write_finalize(callid, &fs_info->vfs_info, size); … … 181 181 } 182 182 183 futex_down(&fs_head_futex); 184 fibril_inc_sercount(); 183 fibril_mutex_lock(&fs_head_lock); 185 184 186 185 /* … … 192 191 */ 193 192 dprintf("FS is already registered.\n"); 194 fibril_dec_sercount(); 195 futex_up(&fs_head_futex); 193 fibril_mutex_unlock(&fs_head_lock); 196 194 free(fs_info); 197 195 ipc_answer_0(callid, EEXISTS); … … 215 213 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); 216 214 list_remove(&fs_info->fs_link); 217 fibril_dec_sercount(); 218 futex_up(&fs_head_futex); 215 fibril_mutex_unlock(&fs_head_lock); 219 216 free(fs_info); 220 217 ipc_answer_0(callid, EINVAL); … … 234 231 dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); 235 232 list_remove(&fs_info->fs_link); 236 fibril_dec_sercount(); 237 futex_up(&fs_head_futex); 233 fibril_mutex_unlock(&fs_head_lock); 238 234 ipc_hangup(fs_info->phone); 239 235 free(fs_info); … … 249 245 dprintf("Client suggests wrong size of PFB, size = %d\n", size); 250 246 list_remove(&fs_info->fs_link); 251 fibril_dec_sercount(); 252 futex_up(&fs_head_futex); 247 fibril_mutex_unlock(&fs_head_lock); 253 248 ipc_hangup(fs_info->phone); 254 249 free(fs_info); … … 274 269 ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle); 275 270 276 fibril_dec_sercount(); 277 futex_up(&fs_head_futex); 271 fibril_mutex_unlock(&fs_head_lock); 278 272 279 273 dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n", … … 298 292 * phone_futex and keep it until vfs_release_phone(). 299 293 */ 300 f utex_down(&fs_head_futex);294 fibril_mutex_lock(&fs_head_lock); 301 295 link_t *cur; 302 296 fs_info_t *fs; … … 304 298 fs = list_get_instance(cur, fs_info_t, fs_link); 305 299 if (fs->fs_handle == handle) { 306 futex_up(&fs_head_futex); 307 /* 308 * For now, take the futex unconditionally. 309 * Oh yeah, serialization rocks. 310 * It will be up'ed in vfs_release_phone(). 311 */ 312 futex_down(&fs->phone_futex); 313 /* 314 * Avoid deadlock with other fibrils in the same thread 315 * by disabling fibril preemption. 316 */ 317 fibril_inc_sercount(); 300 fibril_mutex_unlock(&fs_head_lock); 301 fibril_mutex_lock(&fs->phone_lock); 318 302 return fs->phone; 319 303 } 320 304 } 321 f utex_up(&fs_head_futex);305 fibril_mutex_unlock(&fs_head_lock); 322 306 return 0; 323 307 } … … 331 315 bool found = false; 332 316 333 /* 334 * Undo the fibril_inc_sercount() done in vfs_grab_phone(). 335 */ 336 fibril_dec_sercount(); 337 338 futex_down(&fs_head_futex); 317 fibril_mutex_lock(&fs_head_lock); 339 318 link_t *cur; 340 319 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { … … 342 321 if (fs->phone == phone) { 343 322 found = true; 344 f utex_up(&fs_head_futex);345 f utex_up(&fs->phone_futex);323 fibril_mutex_unlock(&fs_head_lock); 324 fibril_mutex_unlock(&fs->phone_lock); 346 325 return; 347 326 } 348 327 } 349 f utex_up(&fs_head_futex);328 fibril_mutex_unlock(&fs_head_lock); 350 329 351 330 /* … … 358 337 * 359 338 * @param name File system name. 360 * @param lock If true, the function will down and upthe361 * fs_head_ futex.339 * @param lock If true, the function will lock and unlock the 340 * fs_head_lock. 362 341 * 363 342 * @return File system handle or zero if file system not found. … … 368 347 369 348 if (lock) 370 f utex_down(&fs_head_futex);349 fibril_mutex_lock(&fs_head_lock); 371 350 link_t *cur; 372 351 for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { … … 378 357 } 379 358 if (lock) 380 f utex_up(&fs_head_futex);359 fibril_mutex_unlock(&fs_head_lock); 381 360 return handle; 382 361 }
Note:
See TracChangeset
for help on using the changeset viewer.