To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 3414
3413  |  3415
Subject: 
Re: Question about mm.C in BrickOS
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 13 Aug 2003 21:01:50 GMT
Viewed: 
3089 times
  
In lugnet.robotics.rcx.legos, Michael Martelli wrote:
Hey

My Senior Preoject where I update BrickOS is slowly taking shape (I am actually
trying to do some now, but time is very limited).  This project I am editing the
Memory Managment Alg used by BrickOS.  the first one I am going to add is Next
Fit, it seems to be the easiest to add since it is the same as First Fit except
instead of starting from MM_Start when looking for free block, I need to start
at ptr++ (where ptr is the the last free block found).

It has been a while since I looked at this code or done any programming in any
langauge other that VB.NET (for work).  My OS coding background is becoming very
blurry and I dont understand the a whole block of code very well in mm.c.  Of
the block I understand some statements and conditions but not all, if possible
could someone please hlep me and explain what the block is doing?

Here is the malloc function in mm.c (the block is below after the equal signs):

<snip>


============
1      if(*ptr>=size) {    // big enough?
2        *(ptr-1)=(size_t)ctid;  // set owner
3
4              // split this block?
5        if((*ptr-size)>=MM_SPLIT_THRESH) {
6          next=ptr+size+1;
7          *(next++)=MM_FREE;
8          *(next)=*ptr-size-MM_HEADER_SIZE;
9          mm_try_join(next);
10
11          *ptr=size;
12        }
===========

I've never looked at brickOS code, but here is my take:

By the time you hit line 2, you've found a free block that is big enough.  Line
2 sets the owner of the block.  Line 5 decides if the block is oversized enough
to split.

Line 6 points to the unused part of the block.  Line 7 marks the unused part of
the block as free (part of making the unused part of the block a new block).
Line 8 marks the size of the new block (the unused part of the original block
found at line 2.)

If someone else knows better, please correct me.

Kevin


I know what the jist of the block does but I have a foggy idea of what lines 7
and 8 do.  Any help with those 2 lines and a summary of the block would be
great.  Thanks

They split the oversized block into two blocks, by marking the remainder of the
block as free, and writing in the size.

Kevin


Mike



Message is in Reply To:
  Question about mm.C in BrickOS
 
Hey My Senior Preoject where I update BrickOS is slowly taking shape (I am actually trying to do some now, but time is very limited). This project I am editing the Memory Managment Alg used by BrickOS. the first one I am going to add is Next Fit, it (...) (21 years ago, 13-Aug-03, to lugnet.robotics.rcx.legos)

7 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR