Brain (err... on second thoughts, maybe core) dump

Wednesday, July 20, 2005

Question...

I have not been able to post here for quite a while, mainly due to lack of time. So thought of updating the blog with a question that I heard today. Its technical of course ;-)

Write a program to find out if the system stack is growing from higher address to lower address or from lower address to higher address... Pretty simple actually, but worth a shot.

Send your answers to me by mail (mailto: thisisgiri@gmail.com) and I will publish the answer after a couple of days...

P.S: This is very simple, and hence there are no prizes for cracking it ;-)

11 Comments:

Blogger Unknown said...

cool - even i have a C++ question. will pose(t) it in a few days ;)

6:14 PM

 
Blogger Unknown said...

You people are planning to make blogspot a place to find interview questions.. eh!? cool anyways :-)

1:48 PM

 
Blogger Unknown said...

post the solution dude!

8:59 AM

 
Blogger Sub Zero said...

Like I said, this one was pretty simple. All you had to do was compare the addresses of local variables from 2 consecutively called functions. As in:

int * bar()
{
int x;
return &x;
}
void foo()
{
int x;
int *px = &x;
int *py = bar();
/* (px > py) ? Higher to lower : Lower to higher */
}

int main()
{
foo();
return 0;
}

Incidentally, HP on PA_RISC seems to be the only case that I have seen where the stack grows from lower address to higher address. Most others like AIX on PowerPC, Solaris on SPARC and Linux on x86 all seem to grow the stack from higher address to lower address.

10:26 AM

 
Blogger Unknown said...

HP is unique!!!! :D

8:54 AM

 
Blogger Unknown said...

update mado le!!!!

9:13 AM

 
Blogger Sub Zero said...

I have a code freeze on Aug-10, and I have loads of work... Will update asap...

7:07 PM

 
Blogger Aditya Kulkarni said...

google search ;)

9:53 PM

 
Blogger Unknown said...

what is this photo of PK???? EEEEEKKKSSS

8:59 AM

 
Blogger Sub Zero said...

What google search man, PK?

10:18 AM

 
Blogger Unknown said...

update reqd ...

6:44 PM

 

Post a Comment

<< Home