kop99 wrote:Linux's memory management is so good.
You can understand and reference it. It's good experience.
What do you mean? Is there some book called "Linux's memory management", or are you trying to say that the memory management from Linux sources is readily comprehensible for anyone who knows a bit of C alone?
=============================
GeniusCobyWalker wrote:Luna's progress will continue as soon as pointers are covered in class.
There are several intricacies about pointers, but if you already know basic C maybe you could study again the different parts of the language, as there are little things that one could not know yet.
I had to study a copy of "C by Discovery" by L. S. Foster, and studied like 75% of if from the first chapter and up (the whole chapters). It took me like one month and 1 week, but I greatly improved my understanding of C. I mostly was also in need to understand the pointer usage and syntax. These are the chapters it contains:
Chapter 1: Getting Started
Chapter 2: Gaining Control
Regular things like if, for, etc.
Chapter 3: Basic data Types
Chapter 4: Pointers and Arrays
Here is the main theory about pointers. This is what an assembly programmer would like to study more from this book carefuly to convert something like mov byte[var],1 to var=1, and *pointer=1 I think that should be the same as mov edi,[pointer] ;;; mov byte[edi],1.
Chapter 5: Strings
Chapter 6: Keeping Control
More things like do-while, switch, goto, etc.
Chapter 7: Structuring the Data
Structures, arrays, pointers, bit fields, enum, unions, etc.
Chapter 8: Intraprogram Communication
Didn't study it very much.
Chapter 9: Multidimensional Arrays and Double Indirection
This talks about arrays and compares them with pointers, and also talks about double indirection and arrays of pointers
Chapter 10: Input and Output
I almost didn't study it but the name says it.
Chapter 11: C Library and Preprocessor Facilities
Explains some standard functions from the standard C library as well as how to use the preprocessor.
PART II: The Programmer's Handbook
This is a reference of things like identifiers, operator precedence, etc.
======================================================
If I remember correctly, one of the curious things that was explained is that, if a normal variable like an integer "i" is referenced with "&i" it will be referencing its address, NOT its value, and then if it's referenced as "*&i" would be accessing the value of the variable as if it had plainly been using "i", because the "&i" part would return the address of the variable and the * part would point to whatever is at that memory address,
It also talks about pointer arithmetic and the implications of the different combinations of operators in the syntax precedence.
Things like the differences of:
*pointer
*(pointer+5)
*pointer+5
Other things are the fact that doing something like int *intarray is better than int intarray[100] because *intarray only is a pointer (maybe 32 bits) but intarray[100] has to allocate 100 integer elements from the beginning.
The fact that pointing with a pointer of some type to an arbitrary memory location causes that location to be interpreted as a data of that type.
The fact that the "strings" in printf are like put apart like in assembler and then referenced with a pointer to an array of null-terminated chars, or something like that. That whenever something is put as in 'A' that character is considered a character in C, and if it is "A" it is considered a null-terminated string in C.
The fact that myvar[51] could be accessed as *(myvar+51).
One of the good things of C pointers, contrary to assembly "pointers" is that C pointers do the math. For example, if an integer is 4 bytes and we access *(myint+5) in assembly we won't be accessing [myint+5] but [myint+(5*4)], where 4 is the size of the data type that is referenced by the pointer of that type.
I think that other strange think is the difference between something like *a+=1 and (*a)+=1.
And a lot of other small details.
Some sample source code can be found here:
http://web.archive.org/web/200107110343 ... Discovery/