Subversion Repositories HelenOS

Rev

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

Rev 378 Rev 379
Line 160... Line 160...
160
     */
160
     */
161
    i = b->op->get_order(block);
161
    i = b->op->get_order(block);
162
 
162
 
163
    ASSERT(i < b->max_order);
163
    ASSERT(i < b->max_order);
164
 
164
 
165
    /*
-
 
166
     * See if there is any buddy in the list of order i.
-
 
167
     */
-
 
168
    buddy = b->op->find_buddy(block);
-
 
169
   
-
 
170
    if (buddy && i != b->max_order - 1) {
165
    if (i != b->max_order - 1) {
171
 
-
 
172
        ASSERT(b->op->get_order(buddy) == i);
-
 
173
       
-
 
174
        /*
166
        /*
175
         * Remove buddy from the list of order i.
167
         * See if there is any buddy in the list of order i.
176
         */
168
         */
-
 
169
        buddy = b->op->find_buddy(block);
177
        list_remove(buddy);
170
        if (buddy) {
-
 
171
 
-
 
172
            ASSERT(b->op->get_order(buddy) == i);
178
       
173
       
179
        /*
174
            /*
180
         * Invalidate order of both block and buddy.
175
             * Remove buddy from the list of order i.
181
         */
176
             */
182
        b->op->set_order(block, BUDDY_SYSTEM_INNER_BLOCK);
-
 
183
        b->op->set_order(buddy, BUDDY_SYSTEM_INNER_BLOCK);
177
            list_remove(buddy);
184
       
178
       
185
        /*
179
            /*
-
 
180
             * Invalidate order of both block and buddy.
-
 
181
             */
-
 
182
            b->op->set_order(block, BUDDY_SYSTEM_INNER_BLOCK);
-
 
183
            b->op->set_order(buddy, BUDDY_SYSTEM_INNER_BLOCK);
-
 
184
       
-
 
185
            /*
186
         * Coalesce block and buddy into one block.
186
             * Coalesce block and buddy into one block.
187
         */
187
             */
188
        hlp = b->op->coalesce(block, buddy);
188
            hlp = b->op->coalesce(block, buddy);
189
 
189
 
190
        /*
190
            /*
191
         * Set order of the coalesced block to i + 1.
191
             * Set order of the coalesced block to i + 1.
192
         */
192
             */
193
        b->op->set_order(hlp, i + 1);
193
            b->op->set_order(hlp, i + 1);
194
 
194
 
195
        /*
195
            /*
196
         * Recursively add the coalesced block to the list of order i + 1.
196
             * Recursively add the coalesced block to the list of order i + 1.
197
         */
197
             */
198
        buddy_system_free(b, hlp);
198
            buddy_system_free(b, hlp);
199
    }
-
 
200
    else {
199
            return;
201
        /*
200
        }
202
         * Insert block into the list of order i.
-
 
203
         */
-
 
204
        list_append(block, &b->order[i]);
-
 
205
    }
201
    }
206
 
202
 
-
 
203
    /*
-
 
204
     * Insert block into the list of order i.
-
 
205
     */
-
 
206
    list_append(block, &b->order[i]);
-
 
207
 
207
}
208
}