Changeset 1a1744e in mainline
- Timestamp:
- 2008-06-23T18:49:45Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1bb3766
- Parents:
- 08a19ba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/frame.c
r08a19ba r1a1744e 59 59 #include <adt/list.h> 60 60 #include <synch/spinlock.h> 61 #include <synch/mutex.h> 62 #include <synch/condvar.h> 61 63 #include <arch/asm.h> 62 64 #include <arch.h> … … 104 106 static zones_t zones; 105 107 108 /* 109 * Synchronization primitives used to sleep when there is no memory 110 * available. 111 */ 112 mutex_t zones_mtx; 113 condvar_t zones_cv; 114 int new_freed_mem = false; 106 115 107 116 /********************/ … … 992 1001 if (!zone) { 993 1002 /* 994 * TODO: Sleep untilframes are available again.1003 * Sleep until some frames are available again. 995 1004 */ 1005 if (flags & FRAME_ATOMIC) { 1006 interrupts_restore(ipl); 1007 return 0; 1008 } 1009 1010 #ifdef CONFIG_DEBUG 1011 printf("Thread %" PRIu64 " falling asleep, low memory.\n", THREAD->tid); 1012 #endif 1013 1014 mutex_lock(&zones_mtx); 1015 if (!new_freed_mem) 1016 condvar_wait(&zones_cv, &zones_mtx); 1017 new_freed_mem = false; 1018 mutex_unlock(&zones_mtx); 1019 1020 #ifdef CONFIG_DEBUG 1021 printf("Thread %" PRIu64 " woken up, memory available.\n", THREAD->tid); 1022 #endif 1023 996 1024 interrupts_restore(ipl); 997 998 if (flags & FRAME_ATOMIC)999 return 0;1000 1001 panic("Sleep not implemented.\n");1002 1025 goto loop; 1003 1026 } … … 1029 1052 1030 1053 ipl = interrupts_disable(); 1031 1054 1032 1055 /* 1033 1056 * First, find host frame zone for addr. 1034 1057 */ 1035 zone = find_zone_and_lock(pfn, NULL);1058 zone = find_zone_and_lock(pfn, NULL); 1036 1059 ASSERT(zone); 1037 1060 1038 zone_frame_free(zone, pfn -zone->base);1061 zone_frame_free(zone, pfn - zone->base); 1039 1062 1040 1063 spinlock_unlock(&zone->lock); 1064 1065 /* 1066 * Signal that some memory has been freed. 1067 */ 1068 mutex_lock(&zones_mtx); 1069 new_freed_mem = true; 1070 condvar_broadcast(&zones_cv); 1071 mutex_unlock(&zones_mtx); 1072 1041 1073 interrupts_restore(ipl); 1042 1074 } … … 1117 1149 frame_mark_unavailable(0, 1); 1118 1150 } 1151 1152 mutex_initialize(&zones_mtx, MUTEX_ACTIVE); /* mimic spinlock */ 1153 condvar_initialize(&zones_cv); 1119 1154 } 1120 1155
Note:
See TracChangeset
for help on using the changeset viewer.