OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 12:45 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Why Xinu OS rounds stack size when creating a new process?
PostPosted: Wed Mar 14, 2018 8:44 am 
Offline

Joined: Wed Mar 14, 2018 8:07 am
Posts: 6
I'm taking a look into the Xinu's code trying to understand what some parts of the code does in the system.

In the function create, that creates a new process, the stack size of the process, an argument defined by the user, is rounded with a function called roundew. I read the docs but I'm not sure if I understand exactly what that function does and why is needed to do that with size of the stack.

Is it just a 4-byte memory alignment? I'm learning about this subject right now, so I don't understand exactly why memory alignment is so important and how an OS implements it.


Top
 Profile  
 
 Post subject: Re: Why Xinu OS rounds stack size when creating a new proces
PostPosted: Wed Mar 14, 2018 12:03 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
On i386, the stack should be 4-byte aligned. On x86_64, the stack should be 8-byte aligned. But to comply with the System V ABI, the stack must be 16-byte aligned when you call a function. I haven't looked into the source code you mention, nor have I ever heard about it, but this is what I do know about stack alignment on the x86.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: Why Xinu OS rounds stack size when creating a new proces
PostPosted: Wed Mar 14, 2018 3:58 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 642
Location: Ukraine, Bachmut
Aligning stack pointer on 8 bytes on 32 bits and on 16 bytes on 64 bits is common not only on x86. An old mips supplement from SCO, that that describes calling conventions and all those elf platform specific things, honestly admits, that even though the processor wants 4-byte alignment for its words (4 bytes) at the best, OS environment "traditionally" wanted it to be 8-byte aligned... It's as much a mystery, roots of which have sank in history, as this XINU thing I guess. :D

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 117 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group