Heise reports from SCO Forum
Heise reports from SCO Forum
Posted Aug 19, 2003 14:40 UTC (Tue) by mjr (guest, #6979)In reply to: Heise reports from SCO Forum by laurent
Parent article: Heise reports from SCO Forum
Yep, what fun. For reference, roughly the same thing is also in 2.11BSD.
Posted Aug 19, 2003 14:46 UTC (Tue)
by BrucePerens (guest, #2510)
[Link] (12 responses)
Bruce
Posted Aug 19, 2003 14:50 UTC (Tue)
by kunitz (subscriber, #3965)
[Link] (9 responses)
It seems to be that one: Lion's Commentary on UNIX with Source Code
Posted Aug 19, 2003 15:06 UTC (Tue)
by BrucePerens (guest, #2510)
[Link] (8 responses)
Bruce
Posted Aug 19, 2003 15:11 UTC (Tue)
by cdamian (subscriber, #1271)
[Link]
Posted Aug 19, 2003 15:20 UTC (Tue)
by LenZ (subscriber, #1051)
[Link]
FWIW, It does include a quite similar looking pseudocode example for the
malloc() routine:
Not sure, if this is helpful in any way...
Posted Aug 19, 2003 15:24 UTC (Tue)
by rfunk (subscriber, #4054)
[Link] (3 responses)
Posted Aug 19, 2003 15:30 UTC (Tue)
by rfunk (subscriber, #4054)
[Link] (1 responses)
Posted Aug 19, 2003 18:03 UTC (Tue)
by rfunk (subscriber, #4054)
[Link]
Posted Aug 19, 2003 15:32 UTC (Tue)
by rfunk (subscriber, #4054)
[Link]
Posted Aug 19, 2003 15:28 UTC (Tue)
by kunitz (subscriber, #3965)
[Link]
The book has been published in April 1996 and has been declared UNIX book of the Year in 1996 by Unix Review's. The slashdot discussion mentioned, that the book contains a copyright notice by SCO.
Posted Aug 19, 2003 16:17 UTC (Tue)
by lorenb (guest, #14166)
[Link]
malloc: line page
Posted Aug 19, 2003 16:28 UTC (Tue)
by daw (guest, #14169)
[Link] (1 responses)
K&R's version uses a linked list of structs to store the free pointers, while the ancient unix version uses an array of pointers, but the structure of the code snippet is otherwise the same, and it seems likely to me that it had a common ancestor. FWIW, "The Design and Implementation of the 4.4BSD Operating System" (McKusick et al., 1996) also has a short discussion of the kernel malloc implmentation (no code), which mentions the "first-fit" algorithm.
Posted Aug 19, 2003 23:30 UTC (Tue)
by Jocko (guest, #14206)
[Link]
So, there's talk that this code is actually out of a textbook. Anyone know which?Heise reports from SCO Forum
The slashdot discussion one month ago mentioned the Lion's book.Heise reports from SCO Forum
by John Lions and Dennis M. Ritchie, ISBN 1573980137
Can someone with the book verify that the text actually appears, and what page it's on? FYI, here is the Amazon link for the book. Some of the precious Unix source code appears there. I wonder if SCO will sue Amazon. :-)Heise reports from SCO Forum
I don't understand japanese, but this seem to refer to the code and the Lion book: Unix 6th Edition Kernel Source Code and malloc.c
Reference to the Lions book
I don't have have the Lion book, but a german translation of Maurice J. Bach's
Design of the Unix Operating System.
Heise reports from SCO Forum
algorithm malloc /* algorithm to allocate map space */
input: (1) map address /* indicates which map to use */
(2) requested number of units
output: address, if succesful
0, otherwise
{
for (every map entry)
{
if (current map entry can fit in requested units)
{
if (requested units == number of units in entry)
delete entry from map;
else
adjust start address of entry;
return (original address of entry);
}
}
return(0);
}
Well, the Lions book contains all of the Unix v6 kernel code, and it Heise reports from SCO Forum
wasn't quite legal until Caldera blessed it in 1995-1996-ish, after which
it was officialy published.
The book is divided into two parts -- the bare code listing, and the
commentary. This code appear in line 2522, sheet 25 of the code listing.
The commentary is on page 5-2.
As it appears in the Lions book:
Heise reports from SCO Forum
/*
* Allocate size units from the given
* map. Return the base of the allocated
* space.
* Algorithm is first fit.
*/
malloc(mp, size)
struct map *mp;
{
register int a;
register struct map *bp;
for (bp = mp; bp->m_size; bp++) {
if (bp->m_size >= size) {
a = bp->m_addr;
bp->m_addr =+ size;
if ((bp->m_size =- size) == 0)
do {
bp++;
(bp-1)->m_addr = bp->m_addr;
while((bp-1)->m_size = bp->m_size);
return(a);
}
}
return(0);
}
Oops, I missed a closing brace in this line:
Heise reports from SCO Forum
while((bp-1)->m_size = bp->m_size);
Should be:
} while((bp-1)->m_size = bp->m_size);
Oops, it was the Santa Cruz Operation that blessed it, not Caldera. Heise reports from SCO Forum
Caldera didn't get the rights until later, then they opened it all under
the BSD-style license.
It gets more funny, in the foreword, which you can read at amazon.com the author thanks the "old" SCO for allowing the publication of the book.Heise reports from SCO Forum
I have this book and in Chapter 5. The book doesn't have pages per say. This is what's the index:Heise reports from SCO Forum
------------
2528 5-2
2534 5-2
2535 5-2
2536 5-2
2537 5-2
2538 5-2
2539 5-2
2542 5-2
2543 5-2
A very similar malloc implementation also appears in Kernighan & Ritchie's "The C Programming Language," arguably the most common computer programming textbook ever. I have the second edition (1988), and the code is on p. 187, but I imagine it's in the first, 1978, edition as well.Heise reports from SCO Forum
K&R First Edition (1978) has this code on page 175. Sounds like it's the same as the Heise reports from SCO Forum
described Second Edition code.