![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rebuild the Dev of a non UNIX kernel... | DevSer2279 | High Level Programming | 0 | 04-20-2008 09:23 PM |
| Unix Kernel Switching? | jjinno | UNIX for Dummies Questions & Answers | 3 | 08-04-2007 03:22 PM |
| Unix Distribution and Kernel | Dipset | UNIX for Dummies Questions & Answers | 1 | 04-24-2007 12:18 PM |
| How To Shrink /Tmp | unclefab | SUN Solaris | 2 | 01-11-2005 07:43 PM |
| Mac OS X - UNIX kernel based. | Neo | OS X (Apple) | 0 | 06-06-2001 12:03 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Why does UNIX kernel does not shrink?
Hello this is a book problem of chapter 8 william stallings's operating systems..can anyone tells me the accurate solution of it??
The Unix kernel will dynamicaly grow a process’s stack in virtual memory as needed, but it willnever try to shrink it. Consider the case in which a program calls a C function that allocates a local arrayon the stack that consumes 10KB. The kernel will expand the stack segment to accommodate it. When thesubroutine returns, the stack pointer is adjusted and this space could be released by the kernel, but it is notreleased. Explain why it would be possible to shrink the stack at this point, and why the Unix kernel does not shrink it. |
|
||||
|
Another thing is that, in a system where memory is backed by disk, it doesn't have to shrink the stack to get it out of memory. It can swap extra pages to disk instead.
Another issue is how the stack is expanded. Detecting when something uses memory after the end of the current stack is easy -- detect page faults. But how are they supposed to detect when something is not using memory? |
|
||||
|
i am really getting confused with the points..
lets answer this question by taking any assumption.. So, 1. What can be the assumption. 2.Explain why it would be possible to shrink the stack at this point 3. and why the Unix kernel does not shrink it. I think answering these questions will simplify the problem. |
|
||||
|
assumption?
i am really getting confused with the points..
lets answer this question by taking any assumption.. So, 1. What can be the assumption. 2.Explain why it would be possible to shrink the stack at this point 3. and why the Unix kernel does not shrink it. I think answering these questions will simplify the problem. |
|
||||
|
1) What?
2) Explain why it is? I don't think it is. Not efficiently, anyway. 3) It doesn't because that's not an efficient way to do it. I don't think Windows shrinks it either. Like Per said, allocating and freeing memory 10,000 times is expensive. UNIX assumes that memory a process has used once, will probably be used again, so lets it keep it instead of slowing things down by trying to free it all the time. There's a different strategy for paring down unused memory. The operating just looks for memory that hasn't been used recently. It might grab the end of the stack, or it might bite a page out of a shared library you've loaded, or pull page out of your global variables -- then save its contents to disk and give the memory to someone else. The operating system will remember what pieces it's taken from your process, and give them back if you try to use them. Last edited by Corona688; 10-13-2006 at 05:23 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|