Path: chuka.playstation.co.uk!news From: "Nathan Miller" Newsgroups: scee.yaroze.beginners Subject: Re: Many questions for I am confoosed! :o/... Date: Sun, 31 Oct 1999 12:12:34 -0600 Organization: PlayStation Net Yaroze (SCEE) Lines: 92 Message-ID: <7vi161$a6n2@chuka.playstation.co.uk> References: <7vhr5g$4g31@chuka.playstation.co.uk> NNTP-Posting-Host: 98ADA218.ipt.aol.com X-Newsreader: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 >1) We'll start off easy. Basically, why are header files used in C programs. >( *.h as opposed to *.c )? For instance, I use header files for LUT's of >sin/cos values as per normal but couldn't I just initialise an array with a >.c file? The only reason I can see at the moment is that a header file >doesn't require you to call a function eg. InitSinCos();. I know how to >create and include header files no problem but WHY are headers used in C >programs instead of normal c files? Header files are used to define variables and function prototypes. You can include these header files in multiple c (or implimentation) files so that the compiler knows that the functions and variables exist and can be referenced, but they do not have to be implimented readily. To make it all short, it is just the way it is :-) >2) Next, memory areas such as the *heap* or *stack*. Could anyone explain to >me what the heap and stack are and what they are used for? I say this >because I've recently been reading about using 'static' variables to 'move >them off the stack' but I'm lost as to what it means. I always assumed that >the stack was memory allocated for the computer's OS and the heap was memory >that the user sets aside for their own use (using malloc() etc. ). However, >I keep reading threads and info that suggest otherwise. :o/ Please help!!! On the Yaroze, the heap is allocated with InitHeap(), which allocates all available memory to be used by malloc (so your programs do not get overwritten). The stack is used to 'pop' variables on and off when you call a function. The variables can be pushed onto the stack, then popped off in their origional form. This helps to free up the registeres when you have a function with a lot of variables. >3) On to, the dreaded 'cache's'. I've never really understood what cache's >are. I've always understood them as seperate parts of RAM that read/write at >a much quicker rate but I'd like to know more. ;o) In general, what is a >cache and what is it's use? Which leads us on to the next question.... Caches are used to execute code at higher speed. Usually this equates to RAM that exists on the processor itself used for small repetative tasks that can be speeded up by placing it in the cache. >4) The Yaroze has an *I-cache* and a *D-cache*. Lovely, but how and what are >they used for? Apparantly, the I-cache is a 4K instruction scratchpad and >the D-cache is a 1K data scratchpad. Mmmmmm.....yeah. Anyone care to >enlighten me as to what this means!? At the moment I'm just interested in >WHY I would want to access these cache's. I'll leave the 'HOW' questions for >later. :o) The I-cache is used by the processor. When the code is executed from RAM to the processor, the instructions flow through the I-cache, dort of an internal speed-up. The D-cache is available to users, but there is little advantages to be gained by using it on the Yaroze. On the professional dev system, where you can write your own rendering pipeline, the D-cache could be useful for things like transform or lighting calculation code. >5)Lastly, when people mention computer speeds such as 'scanlines' and >'cycles' what does this refer to? Scanlines are used in consoles mostly and are a speed measurement based on the number and frequency of lines that the television displays. Cycles could be anything, but generally refer to clock cycles that occur at a certain frequency (i.e. 33 MHz). The instructions are measured in cycles, i.e. 4 cycles, which is the time it takes for that particular instruction to finish. Basically, cycles are the amount of times the processor executes instructions in a givin time period (usually ms or even us). >All answers are gratefully accepted in plain English, I've yet to get to >grips with the so-called computer tech-lingo. ;o) Well, I tried my best :-) Nathan Miller