Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The .NET stack vs Windows stack

Tags:

stack

.net

The Windows Internal book 5th edition has the following comment in page 360.

The stack size for the initial thread is taken from the image—there’s no way 
to specify another size.

I understand that for Windows OS, each thread is given 4K or 16K (depending on system) stack, and the size is fixed.

Then how about the stack in .NET?

  • How big is the stack?
  • The size of the stack is fixed or variable?
  • Is the stack allocated for each thread just like the case of Windows?
like image 812
prosseek Avatar asked Nov 03 '10 15:11

prosseek


People also ask

What is Microsoft .NET stack?

The Microsoft stack is a set of applications and tools that are designed to work together—from the back-end data base to coding languages (e.g., C#) and development environments (e.g., Visual Studio), all the way up to platforms and applications, like cloud apps, Microsoft (Office) 365, and business applications like ...

What tech stack is used by Microsoft?

Windows Presentation Foundation (WPF) Most enterprise-grade applications trust Microsoft's technology stack for its dependable performance.

Which is the best stack for web development?

ReactJS and NodeJS are two of the most popular web development stacks in 2022. They are both relatively new and modern frameworks. They are also not language-specific, so developers can use the same skills they use to work on front-end web development projects to work with ReactJS and NodeJS.

Which stack is best to learn?

If you're new to web development, the MEAN or MERN stack are good starting points. These stacks are relatively easy to learn, and they use a single programming language (JavaScript) which makes things simpler.


1 Answers

Yes, the size for the startup thread is determined by a value in the .EXE file header. Necessarily so, it is the OS that creates the thread, before any code in the program can run. It calls the entrypoint of the program, CorExeMain().

The managed compiler you use writes that value into the EXE file header. Current .NET compilers select 1 MB when you target x86 or Any CPU, 4 MB when you target x64. This is however not fixed, you can modify the value with the Editbin.exe utility, /STACK command line option. You could use this post-build event to get a 2MB stack:

  set path=%path%;$(DevEnvDir);$(DevEnvDir)..\..\vc\bin
  editbin.exe /STACK:2097152 "$(TargetPath)"

The stack size for threads that you create yourself are under your control, the Thread class constructor has overloads that lets you specify the size. You cannot make it too small, if clips the value to 256 KB. That's necessary, the just-in-time compiler also uses the stack.

like image 197
Hans Passant Avatar answered Sep 19 '22 18:09

Hans Passant