Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!pasteur!ucbvax!hoser.berkeley.edu!bryce From: bryce@hoser.berkeley.edu (Bryce Nesbitt) Newsgroups: comp.sys.amiga Subject: Re: SetStack Message-ID: <22692@ucbvax.BERKELEY.EDU> Date: 21 Jan 88 04:15:43 GMT References: <8801202127.AA10280@cory.Berkeley.EDU> Sender: usenet@ucbvax.BERKELEY.EDU Lines: 38 In article <> dillon@CORY.BERKELEY.EDU (Matt Dillon) writes: | |>; SetStack(newstack,size) |>;FUNCTION |>; This function points the current process' stack to a new memory |>; location. The active part of the old stack is duplicated, so no |>; context is lost. SetStack() also tickles the proper fields in the task |>; structure to tell the system about the change. At this time it does |>; not deallocate the old stack. | | You CAN'T deallocate the old stack, Because it will be deallocated |by the parent task... That is exactly why it does not. It would be desirable if it could. An unused stack is wasted memory. |Also, the parent may |depend on the task structure not changing, so it is probably better NOT to |diddle the pointers... at least they should be the same on program exit. pr_ReturnAddr always points to the top-4 of the *currently* executing stack. The size of the currently executing stack is stored in the long at top-4. At top-8 is the return address used during process removal. This is the only thing SetStack() does or should diddle with. Not keeping pr_ReturnAddr as a pointer to the *currently executing* stack destroys stack checking algorithms. With it you can have a nice clean stack check every time the process is switched out. Matter of fact, I'm running that right now. |\ /| . Ack! (NAK, SOH, EOT) {o O} . bryce@hoser.berkeley.EDU -or- ucbvax!hoser!bryce (or try "cogsci") (") U "As an engineer, I only set the value of a product... not the cost." -Bryce Nesbitt