Changeset c2ab3f4 in mainline
- Timestamp:
- 2010-04-28T21:12:04Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c050399
- Parents:
- b8f7ea78 (diff), 55821eea (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- kernel/generic/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
rb8f7ea78 rc2ab3f4 46 46 #include <mm/frame.h> 47 47 #include <mm/as.h> 48 #include <synch/ spinlock.h>48 #include <synch/mutex.h> 49 49 #include <syscall/copy.h> 50 50 #include <adt/btree.h> … … 54 54 55 55 /** This lock protects the parea_btree. */ 56 SPINLOCK_INITIALIZE(parea_lock);56 static mutex_t parea_lock; 57 57 58 58 /** B+tree with enabled physical memory areas. */ … … 63 63 { 64 64 btree_create(&parea_btree); 65 mutex_initialize(&parea_lock, MUTEX_PASSIVE); 65 66 } 66 67 … … 72 73 void ddi_parea_register(parea_t *parea) 73 74 { 74 ipl_t ipl = interrupts_disable(); 75 spinlock_lock(&parea_lock); 75 mutex_lock(&parea_lock); 76 76 77 77 /* … … 80 80 btree_insert(&parea_btree, (btree_key_t) parea->pbase, parea, NULL); 81 81 82 spinlock_unlock(&parea_lock); 83 interrupts_restore(ipl); 82 mutex_unlock(&parea_lock); 84 83 } 85 84 … … 141 140 spinlock_unlock(&zones.lock); 142 141 143 spinlock_lock(&parea_lock);142 mutex_lock(&parea_lock); 144 143 btree_node_t *nodep; 145 144 parea_t *parea = (parea_t *) btree_search(&parea_btree, … … 147 146 148 147 if ((!parea) || (parea->frames < pages)) { 149 spinlock_unlock(&parea_lock);148 mutex_unlock(&parea_lock); 150 149 goto err; 151 150 } 152 151 153 spinlock_unlock(&parea_lock);152 mutex_unlock(&parea_lock); 154 153 goto map; 155 154 } … … 161 160 162 161 map: 163 spinlock_lock(&TASK->lock);164 162 interrupts_restore(ipl); 163 165 164 if (!as_area_create(TASK->as, flags, pages * PAGE_SIZE, vp, 166 165 AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) { … … 169 168 * We report it using ENOMEM. 170 169 */ 171 spinlock_unlock(&TASK->lock);172 interrupts_restore(ipl);173 170 return ENOMEM; 174 171 } … … 177 174 * Mapping is created on-demand during page fault. 178 175 */ 179 180 spinlock_unlock(&TASK->lock);181 interrupts_restore(ipl);182 176 return 0; 183 177 } -
kernel/generic/src/mm/frame.c
rb8f7ea78 rc2ab3f4 1033 1033 spinlock_unlock(&zones.lock); 1034 1034 interrupts_restore(ipl); 1035 1036 if (!THREAD) 1037 panic("Cannot wait for memory to become available."); 1035 1038 1036 1039 /* -
kernel/generic/src/mm/slab.c
rb8f7ea78 rc2ab3f4 555 555 * Initialize mag_cache structure in slab cache 556 556 */ 557 static voidmake_magcache(slab_cache_t *cache)557 static bool make_magcache(slab_cache_t *cache) 558 558 { 559 559 unsigned int i; … … 562 562 563 563 cache->mag_cache = malloc(sizeof(slab_mag_cache_t) * config.cpu_count, 564 0); 564 FRAME_ATOMIC); 565 if (!cache->mag_cache) 566 return false; 567 565 568 for (i = 0; i < config.cpu_count; i++) { 566 569 memsetb(&cache->mag_cache[i], sizeof(cache->mag_cache[i]), 0); … … 568 571 "slab_maglock_cpu"); 569 572 } 573 return true; 570 574 } 571 575 … … 597 601 spinlock_initialize(&cache->maglock, "slab_maglock"); 598 602 if (!(cache->flags & SLAB_CACHE_NOMAGAZINE)) 599 make_magcache(cache);603 (void) make_magcache(cache); 600 604 601 605 /* Compute slab sizes, object counts in slabs etc. */ … … 923 927 SLAB_CACHE_MAGDEFERRED) 924 928 continue; 925 make_magcache(s);929 (void) make_magcache(s); 926 930 s->flags &= ~SLAB_CACHE_MAGDEFERRED; 927 931 } -
kernel/generic/src/synch/mutex.c
rb8f7ea78 rc2ab3f4 40 40 #include <synch/synch.h> 41 41 #include <debug.h> 42 #include <arch.h> 42 43 43 44 /** Initialize mutex. … … 69 70 int rc; 70 71 71 if (mtx->type == MUTEX_PASSIVE ) {72 if (mtx->type == MUTEX_PASSIVE && THREAD) { 72 73 rc = _semaphore_down_timeout(&mtx->sem, usec, flags); 73 74 } else { 74 ASSERT(mtx->type == MUTEX_ACTIVE );75 ASSERT(mtx->type == MUTEX_ACTIVE || !THREAD); 75 76 ASSERT(usec == SYNCH_NO_TIMEOUT); 76 77 ASSERT(!(flags & SYNCH_FLAGS_INTERRUPTIBLE)); -
kernel/generic/src/sysinfo/stats.c
rb8f7ea78 rc2ab3f4 38 38 #include <sysinfo/stats.h> 39 39 #include <sysinfo/sysinfo.h> 40 #include <synch/spinlock.h> 41 #include <synch/mutex.h> 40 42 #include <time/clock.h> 41 43 #include <mm/frame.h> … … 68 70 static load_t avenrdy[LOAD_STEPS] = {0, 0, 0}; 69 71 70 /** Load calculation spinlock */71 SPINLOCK_STATIC_INITIALIZE_NAME(load_lock, "load_lock");72 /** Load calculation lock */ 73 static mutex_t load_lock; 72 74 73 75 /** Get system uptime … … 344 346 345 347 /* Interrupts are already disabled */ 346 spinlock_lock(& (thread->lock));348 spinlock_lock(&thread->lock); 347 349 348 350 /* Record the statistics and increment the iterator */ … … 350 352 (*iterator)++; 351 353 352 spinlock_unlock(& (thread->lock));354 spinlock_unlock(&thread->lock); 353 355 354 356 return true; … … 615 617 } 616 618 617 /* To always get consistent values acquire the spinlock */ 618 ipl_t ipl = interrupts_disable(); 619 spinlock_lock(&load_lock); 619 /* To always get consistent values acquire the mutex */ 620 mutex_lock(&load_lock); 620 621 621 622 unsigned int i; … … 623 624 stats_load[i] = avenrdy[i] << LOAD_FIXED_SHIFT; 624 625 625 spinlock_unlock(&load_lock); 626 interrupts_restore(ipl); 626 mutex_unlock(&load_lock); 627 627 628 628 return ((void *) stats_load); … … 655 655 656 656 /* Mutually exclude with get_stats_load() */ 657 ipl_t ipl = interrupts_disable(); 658 spinlock_lock(&load_lock); 657 mutex_lock(&load_lock); 659 658 660 659 unsigned int i; … … 662 661 avenrdy[i] = load_calc(avenrdy[i], load_exp[i], ready); 663 662 664 spinlock_unlock(&load_lock); 665 interrupts_restore(ipl); 663 mutex_unlock(&load_lock); 666 664 667 665 thread_sleep(LOAD_INTERVAL); … … 674 672 void stats_init(void) 675 673 { 674 mutex_initialize(&load_lock, MUTEX_PASSIVE); 675 676 676 sysinfo_set_item_fn_val("system.uptime", NULL, get_stats_uptime); 677 677 sysinfo_set_item_fn_data("system.cpus", NULL, get_stats_cpus); -
kernel/generic/src/sysinfo/sysinfo.c
rb8f7ea78 rc2ab3f4 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.