operating system - The stack size used in kernel development -


i'm developing operating system , rather programming kernel, i'm designing kernel. operating system targeted @ x86 architecture , target modern computers. estimated number of required ram 256mb or more.

what size make stack each thread run on system? should try design system in such way stack can extended automatically if maximum length reached?

i think if remember correctly page in ram 4k or 4096 bytes , doesn't seem lot me. can see times, when using lots of recursion, want have more 1000 integars in ram @ once. now, real solution have program doing using malloc , manage own memory resources, know user opinion on this.

is 4k big enough stack modern computer programs? should stack bigger that? should stack auto-expanding accommodate types of sizes? i'm interested in both practical developer's standpoint , security standpoint.

is 4k big stack? considering normal program execution, point of view of classes in c++, notice source code tends malloc/new data needs when classes created, minimize data being thrown around in function call.

what haven't gotten size of processor's cache memory. ideally, think stack reside in cache speed things , i'm not sure if need achieve this, or if processor can handle me. planning on using regular boring old ram testing purposes. can't decide. options?

stack size depends on threads doing. advice:

  • make stack size parameter @ thread creation time (different threads different things, , hence need different stack sizes)
  • provide reasonable default don't want bothered specifying stack size (4k appeals control freak in me, cause stack-profligate to, er, signal pretty quickly)
  • consider how detect , deal stack overflow. detection can tricky. can put guard pages--empty--at ends of stack, , work. relying on behavior of bad thread not leap on moat , start polluting lays beyond. won't happen...but then, that's makes tough bugs tough. airtight mechanism involves hacking compiler generate stack checking code. dealing stack overflow, need dedicated stack somewhere else on offending thread (or guardian angel, whoever decide is--you're os designer, after all) run.
  • i recommend marking ends of stack distinctive pattern, when threads run on ends (and do), can @ least go in post-mortem , see did in fact run off stack. page of 0xdeadbeef or handy.

by way, x86 page sizes 4k, not have be. can go 64k size or larger. usual reason larger pages avoid tlb misses. again, make kernel configuration or run-time parameter.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -