Subversion Repositories HelenOS-historic

Rev

Rev 368 | Rev 374 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 368 Rev 373
Line 113... Line 113...
113
    tmp = zone->free_head.next;
113
    tmp = zone->free_head.next;
114
    frame = list_get_instance(tmp, frame_t, link);
114
    frame = list_get_instance(tmp, frame_t, link);
115
 
115
 
116
    frame->refcount++;
116
    frame->refcount++;
117
    list_remove(tmp);           /* remove frame from free_head */
117
    list_remove(tmp);           /* remove frame from free_head */
118
    list_append(tmp, &zone->busy_head); /* append frame to busy_head */
-
 
119
    zone->free_count--;
118
    zone->free_count--;
120
    zone->busy_count++;
119
    zone->busy_count++;
121
   
120
   
122
    v = zone->base + (frame - zone->frames) * FRAME_SIZE;
121
    v = zone->base + (frame - zone->frames) * FRAME_SIZE;
123
   
122
   
Line 178... Line 177...
178
   
177
   
179
    frame = &zone->frames[(addr - zone->base)/FRAME_SIZE];
178
    frame = &zone->frames[(addr - zone->base)/FRAME_SIZE];
180
    ASSERT(frame->refcount);
179
    ASSERT(frame->refcount);
181
 
180
 
182
    if (!--frame->refcount) {
181
    if (!--frame->refcount) {
183
        list_remove(&frame->link);          /* remove frame from busy_head */
-
 
184
        list_append(&frame->link, &zone->free_head);    /* append frame to free_head */
182
        list_append(&frame->link, &zone->free_head);    /* append frame to free_head */
185
        zone->free_count++;
183
        zone->free_count++;
186
        zone->busy_count--;
184
        zone->busy_count--;
187
    }
185
    }
188
   
186
   
Line 193... Line 191...
193
}
191
}
194
 
192
 
195
/** Mark frame not free.
193
/** Mark frame not free.
196
 *
194
 *
197
 * Find respective frame structrue for supplied addr.
195
 * Find respective frame structrue for supplied addr.
198
 * Increment frame reference count and move the frame structure to busy list.
196
 * Increment frame reference count and remove the frame structure from free list.
199
 *
197
 *
200
 * @param addr Address of the frame to be marked. It must be a multiple of FRAME_SIZE.
198
 * @param addr Address of the frame to be marked. It must be a multiple of FRAME_SIZE.
201
 */
199
 */
202
void frame_not_free(__address addr)
200
void frame_not_free(__address addr)
203
{
201
{
Line 239... Line 237...
239
 
237
 
240
    if (!frame->refcount) {
238
    if (!frame->refcount) {
241
        frame->refcount++;
239
        frame->refcount++;
242
 
240
 
243
        list_remove(&frame->link);          /* remove frame from free_head */
241
        list_remove(&frame->link);          /* remove frame from free_head */
244
        list_append(&frame->link, &zone->busy_head);    /* append frame to busy_head */
-
 
245
        zone->free_count--;
242
        zone->free_count--;
246
        zone->busy_count++;
243
        zone->busy_count++;
247
    }
244
    }
248
   
245
   
249
    spinlock_unlock(&zone->lock);  
246
    spinlock_unlock(&zone->lock);  
Line 311... Line 308...
311
 
308
 
312
        z->free_count = cnt;
309
        z->free_count = cnt;
313
        list_initialize(&z->free_head);
310
        list_initialize(&z->free_head);
314
 
311
 
315
        z->busy_count = 0;
312
        z->busy_count = 0;
316
        list_initialize(&z->busy_head);
-
 
317
       
313
       
318
        z->frames = (frame_t *) malloc(cnt * sizeof(frame_t));
314
        z->frames = (frame_t *) malloc(cnt * sizeof(frame_t));
319
        if (!z->frames) {
315
        if (!z->frames) {
320
            free(z);
316
            free(z);
321
            return NULL;
317
            return NULL;