Changeset 14 for tags/minix3.1.2a-orig
- Timestamp:
- Jun 4, 2011, 7:31:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/minix3.1.2a-orig/minix/servers/pm/alloc.c
r9 r14 68 68 * needed for FORK or EXEC. Swap other processes out if needed. 69 69 */ 70 register struct hole *hp, *prev_ptr; 70 register struct hole *hp, *prev_ptr, *best, *prev_best; 71 int delta=-1; 71 72 phys_clicks old_base; 72 73 73 do { 74 74 prev_ptr = NIL_HOLE; 75 hp = hole_head; 76 while (hp != NIL_HOLE && hp->h_base < swap_base) { 77 if (hp->h_len >= clicks) { 78 /* We found a hole that is big enough. Use it. */ 79 old_base = hp->h_base; /* remember where it started */ 80 hp->h_base += clicks; /* bite a piece off */ 81 hp->h_len -= clicks; /* ditto */ 82 83 /* Remember new high watermark of used memory. */ 84 if(hp->h_base > high_watermark) 85 high_watermark = hp->h_base; 86 87 /* Delete the hole if used up completely. */ 88 if (hp->h_len == 0) del_slot(prev_ptr, hp); 89 90 /* Return the start address of the acquired block. */ 91 return(old_base); 92 } 93 94 prev_ptr = hp; 95 hp = hp->h_next; 96 } 97 } while (swap_out()); /* try to swap some other process out */ 75 hp = hole_head; 76 while (hp != NIL_HOLE && hp->h_base < swap_base) { 77 printf("base:%d len:%d (req:%d)\n", hp->h_base, hp->h_len, clicks); 78 if (hp->h_len == clicks) { 79 /* We found a hole that is big enough. Use it. */ 80 old_base = hp->h_base; /* remember where it started */ 81 hp->h_base += clicks; /* bite a piece off */ 82 hp->h_len -= clicks; /* ditto */ 83 /* Remember new high watermark of used memory. */ 84 if(hp->h_base > high_watermark) 85 high_watermark = hp->h_base; 86 /* Delete the hole if used up completely. */ 87 if (hp->h_len == 0) del_slot(prev_ptr, hp); 88 /* Return the start address of the acquired block. */ 89 printf("Allocazione 'perfetta'\n"); 90 return(old_base); 91 if (hp->h_len > clicks) { 92 if (hp->h_len - clicks < delta || delta == -1){ 93 delta = hp->h_len - clicks; 94 best = hp; 95 prev_best = prev_ptr; 96 } 97 prev_ptr = hp; 98 hp = hp->h_next; 99 if (delta > -1){ 100 printf("Allocazione con delta=%d\n",delta); 101 old_base = best->h_base; /* remember where it started */ 102 best->h_base += clicks; /* bite a piece off */ 103 best->h_len -= clicks; /* cioe` delta */ 104 /* Remember new high watermark of used memory. */ 105 if(best->h_base > high_watermark) 106 high_watermark = best->h_base; 107 /* Delete the hole if used up completely. */ 108 if (best->h_len == 0) printf("Non dovrebbe mai succedere\n"); 109 /* Return the start address of the acquired block. */ 110 return(old_base); 111 } while (swap_out()); /* try to swap some other process out */ 98 112 return(NO_MEM); 99 113 }
Note:
See TracChangeset
for help on using the changeset viewer.