Results 1 to 4 of 4
My questions is a simple/hard one, whats a stack on an intel machine? I don't a need lesson on how to use one for I already know how, its just ...
- 02-10-2008 #1
Intel Stack
My questions is a simple/hard one, whats a stack on an intel machine? I don't a need lesson on how to use one for I already know how, its just that I really don't know very much about them. Like how come you can automatically allocate memory on them by simply moving the stack pointer. Is this just the way its designed, the intel chip, increase or decrease the value in esp and increase or decrease memory available to the program. Can a user program create stacks as needed?
I guest what I,m looking for is a really detailed article on the stack for intel cpus
So if anyone knows of a good website please let me know
Thanks in advance...Gerard4143
P.S. I have read the 4 big Intel Manuals
- 02-10-2008 #2
After ten hours I see no replies about useful web pages, so I'll jump right in.
The chip implements virtual memory. This allows the operating system to implement swapping; segments of memory which have not been used for some time can be swapped out to disk, and the segment is marked as not present (or something). When the program using that segment accesses it again, a segment violation occurs. This causes the operating system to examine its information about the process, determine from its own bookkeeping that the segment has been swapped out, read it into some place in physical memory, update the hardware tables to show this, and re-execute the offending instruction.how come you can automatically allocate memory on them by simply moving the stack pointer
In the case where a pointer points to a completely unauthorized place (the NULL pointer is a prime example), the operating system throws up in disgust and aborts the process, sending the segment violation allegation to the process's parent.
Stack segments are a special case of this. If you modify the stack pointer to point to a location beyond the stack size, the operating system can make the decision either to change the stack size or to throw up in disgust, as previously described.
An operating system can provide this support for as many stacks per process as it wants. As far as I know, Linux provides this support for only one stack per process or thread.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 02-10-2008 #3Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Threads in a single program share the same address space. This allows multiple threads to operate on the same data without the use IPC mechanisms.
If it is desirable to duplicate a certain variable so that each thread has a separate copy you can use a thread-specific data area with the pthread_key_create function.
Each thread has its own call stack, however.
This allows each thread to execute different code and to call and return from subroutines in the usual way.
Regards
- 02-10-2008 #4
stack question


Reply With Quote
