Discussion:
Another Stack Question
(too old to reply)
David Hershey
2005-02-17 04:04:37 UTC
Permalink
In discussion this morning (2/16), it was suggested to us that the
argument block be placed at the very end of the User_Context memory and
that the stack would fit between the data segment and the argument
block. The Start_User_Thread () description on the webpage mentions that
The user process stack you created starts at the very end of the executable image...
Which of these implementations is correct, or does it matter as long as
we are consistent?

- David
Tom Brubaker
2005-02-17 04:55:22 UTC
Permalink
It seems to me that placing the argument block at the end of the memory and
placing the stack betwee it and the data segment is essentially equivalent
to placing the argument block _in_ the stack.

What I don't understand is why argblock.h defines struct Argument_Block, yet
argblock.c just fills out this structure with pointer arithmetic...
Post by David Hershey
In discussion this morning (2/16), it was suggested to us that the
argument block be placed at the very end of the User_Context memory and
that the stack would fit between the data segment and the argument block.
The Start_User_Thread () description on the webpage mentions that
The user process stack you created starts at the very end of the executable image...
Which of these implementations is correct, or does it matter as long as we
are consistent?
- David
Iulian Neamtiu
2005-02-17 17:50:31 UTC
Permalink
Here's the layout:

Data/Text | Stack <---- | Args |<- end, top of user memory
^
|
stackAddr/argAddr

The arguments will be placed starting at stackAddr = argAddr (upwards).
The initial stack pointer is stackAddr. You don't overwrite the args
because the stack grows down and Push semantics is: decrement, then
assign.

Iulian
Post by Tom Brubaker
It seems to me that placing the argument block at the end of the memory and
placing the stack betwee it and the data segment is essentially equivalent
to placing the argument block _in_ the stack.
What I don't understand is why argblock.h defines struct Argument_Block, yet
argblock.c just fills out this structure with pointer arithmetic...
Post by David Hershey
In discussion this morning (2/16), it was suggested to us that the
argument block be placed at the very end of the User_Context memory and
that the stack would fit between the data segment and the argument block.
The Start_User_Thread () description on the webpage mentions that
The user process stack you created starts at the very end of the executable image...
Which of these implementations is correct, or does it matter as long as we
are consistent?
- David
William Francis Cladek
2005-02-20 22:26:54 UTC
Permalink
I'm a little confused about the calling of Format_Argument_Block(),
specifically the argBlock and userAddress parameters. Here's how I'm
interpreting it, though: argBlock is a pointer to the location in user
memory indicated by argAddr in Iulian's example below. userAddress is the
actual *value* of argAddr. Is this correct?
Post by Iulian Neamtiu
Data/Text | Stack <---- | Args |<- end, top of user memory
^
|
stackAddr/argAddr
The arguments will be placed starting at stackAddr = argAddr (upwards).
The initial stack pointer is stackAddr. You don't overwrite the args
because the stack grows down and Push semantics is: decrement, then
assign.
Iulian
William Francis Cladek
2005-02-20 22:34:24 UTC
Permalink
One more quick question... in the comment hints for Load_User_Program, it
says
* - In the created User_Context object, set code entry point
* address, argument block address, and initial kernel stack pointer
* address

In this case are those last two things, the argument block address and
stack pointer address, the same value?

Will
Post by Iulian Neamtiu
Data/Text | Stack <---- | Args |<- end, top of user memory
^
|
stackAddr/argAddr
The arguments will be placed starting at stackAddr = argAddr (upwards).
The initial stack pointer is stackAddr. You don't overwrite the args
because the stack grows down and Push semantics is: decrement, then
assign.
Iulian
Iulian Neamtiu
2005-02-22 15:20:43 UTC
Permalink
Post by William Francis Cladek
One more quick question... in the comment hints for Load_User_Program, it
says
* - In the created User_Context object, set code entry point
* address, argument block address, and initial kernel stack pointer
* address
In this case are those last two things, the argument block address and
stack pointer address, the same value?
They happen to be, for this project. Once we'll get to paging though,
they will be different.

Iulian

Continue reading on narkive:
Loading...