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