Changes in kernel/generic/src/sysinfo/sysinfo.c [b4ad39f:c6218327] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/sysinfo/sysinfo.c
rb4ad39f rc6218327 37 37 #include <print.h> 38 38 #include <syscall/copy.h> 39 #include <synch/ spinlock.h>39 #include <synch/mutex.h> 40 40 #include <arch/asm.h> 41 41 #include <errno.h> … … 52 52 static slab_cache_t *sysinfo_item_slab; 53 53 54 /** Sysinfo spinlock */55 SPINLOCK_STATIC_INITIALIZE_NAME(sysinfo_lock, "sysinfo_lock");54 /** Sysinfo lock */ 55 static mutex_t sysinfo_lock; 56 56 57 57 /** Sysinfo item constructor … … 98 98 sizeof(sysinfo_item_t), 0, sysinfo_item_constructor, 99 99 sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED); 100 101 mutex_initialize(&sysinfo_lock, MUTEX_ACTIVE); 100 102 } 101 103 102 104 /** Recursively find an item in sysinfo tree 103 105 * 104 * Should be called with interrupts disabled 105 * and sysinfo_lock held. 106 * Should be called with sysinfo_lock held. 106 107 * 107 108 * @param name Current sysinfo path suffix. … … 168 169 /** Recursively create items in sysinfo tree 169 170 * 170 * Should be called with interrupts disabled 171 * and sysinfo_lock held. 171 * Should be called with sysinfo_lock held. 172 172 * 173 173 * @param name Current sysinfo path suffix. … … 299 299 { 300 300 /* Protect sysinfo tree consistency */ 301 ipl_t ipl = interrupts_disable(); 302 spinlock_lock(&sysinfo_lock); 301 mutex_lock(&sysinfo_lock); 303 302 304 303 if (root == NULL) … … 311 310 } 312 311 313 spinlock_unlock(&sysinfo_lock); 314 interrupts_restore(ipl); 312 mutex_unlock(&sysinfo_lock); 315 313 } 316 314 … … 332 330 { 333 331 /* Protect sysinfo tree consistency */ 334 ipl_t ipl = interrupts_disable(); 335 spinlock_lock(&sysinfo_lock); 332 mutex_lock(&sysinfo_lock); 336 333 337 334 if (root == NULL) … … 345 342 } 346 343 347 spinlock_unlock(&sysinfo_lock); 348 interrupts_restore(ipl); 344 mutex_unlock(&sysinfo_lock); 349 345 } 350 346 … … 361 357 { 362 358 /* Protect sysinfo tree consistency */ 363 ipl_t ipl = interrupts_disable(); 364 spinlock_lock(&sysinfo_lock); 359 mutex_lock(&sysinfo_lock); 365 360 366 361 if (root == NULL) … … 373 368 } 374 369 375 spinlock_unlock(&sysinfo_lock); 376 interrupts_restore(ipl); 370 mutex_unlock(&sysinfo_lock); 377 371 } 378 372 … … 394 388 { 395 389 /* Protect sysinfo tree consistency */ 396 ipl_t ipl = interrupts_disable(); 397 spinlock_lock(&sysinfo_lock); 390 mutex_lock(&sysinfo_lock); 398 391 399 392 if (root == NULL) … … 406 399 } 407 400 408 spinlock_unlock(&sysinfo_lock); 409 interrupts_restore(ipl); 401 mutex_unlock(&sysinfo_lock); 410 402 } 411 403 … … 420 412 { 421 413 /* Protect sysinfo tree consistency */ 422 ipl_t ipl = interrupts_disable(); 423 spinlock_lock(&sysinfo_lock); 414 mutex_lock(&sysinfo_lock); 424 415 425 416 if (root == NULL) … … 430 421 item->val_type = SYSINFO_VAL_UNDEFINED; 431 422 432 spinlock_unlock(&sysinfo_lock); 433 interrupts_restore(ipl); 423 mutex_unlock(&sysinfo_lock); 434 424 } 435 425 … … 446 436 { 447 437 /* Protect sysinfo tree consistency */ 448 ipl_t ipl = interrupts_disable(); 449 spinlock_lock(&sysinfo_lock); 438 mutex_lock(&sysinfo_lock); 450 439 451 440 if (root == NULL) … … 461 450 } 462 451 463 spinlock_unlock(&sysinfo_lock); 464 interrupts_restore(ipl); 452 mutex_unlock(&sysinfo_lock); 465 453 } 466 454 … … 479 467 /** Dump the structure of sysinfo tree 480 468 * 481 * Should be called with interrupts disabled 482 * and sysinfo_lock held. Because this routine 483 * might take a reasonable long time to proceed, 484 * having the spinlock held is not optimal, but 485 * there is no better simple solution. 469 * Should be called with sysinfo_lock held. 486 470 * 487 471 * @param root Root item of the current (sub)tree. … … 559 543 /* Avoid other functions to mess with sysinfo 560 544 while we are dumping it */ 561 ipl_t ipl = interrupts_disable(); 562 spinlock_lock(&sysinfo_lock); 545 mutex_lock(&sysinfo_lock); 563 546 564 547 if (root == NULL) … … 567 550 sysinfo_dump_internal(root, 0); 568 551 569 spinlock_unlock(&sysinfo_lock); 570 interrupts_restore(ipl); 552 mutex_unlock(&sysinfo_lock); 571 553 } 572 554 573 555 /** Return sysinfo item value determined by name 574 556 * 575 * Should be called with interrupts disabled 576 * and sysinfo_lock held. 557 * Should be called with sysinfo_lock held. 577 558 * 578 559 * @param name Sysinfo path. … … 659 640 * are reading it. 660 641 */ 661 ipl_t ipl = interrupts_disable(); 662 spinlock_lock(&sysinfo_lock); 642 mutex_lock(&sysinfo_lock); 663 643 ret = sysinfo_get_item(path, NULL, dry_run); 664 spinlock_unlock(&sysinfo_lock); 665 interrupts_restore(ipl); 644 mutex_unlock(&sysinfo_lock); 666 645 } 667 646 free(path);
Note:
See TracChangeset
for help on using the changeset viewer.