Page 1 of 2

Information required

Posted: Tue Sep 18, 2012 1:35 pm
by ciberyane
LO que me interesa conocer es la manera como Reactos asigna a Procesos o Hilos los recursos memoria, CPU, perifericos, informacion, etc.

Mi idea es presentarlo en la universidad para que mis compañeros y profesores lo conozcan (a traves de una exposicion a realizarse en un mes)

Por lo que agradeceria cualquier informacion al respecto que puedan brindarme para tal fin :ugeek: :D 8-)

EDIT:
What I want to know is how ReactOS processes or threads allocated to memory resources, CPU, peripherals, information, etc.

My idea is to present it in college so my classmates and teachers know him (through an exhibition to be held in a month)

So I would appreciate any information about it that can give me for that purpose :D

Re: INFORMACION REQUERIDA

Posted: Tue Sep 18, 2012 1:38 pm
by ironek69
please post threads in dedicated spanish forum

Re: INFORMACION REQUERIDA

Posted: Tue Sep 18, 2012 1:45 pm
by ciberyane
The moderator team say me that is better i ask in this place, because is mor crowed :(

What I want to know is how ReactOS processes or threads allocated to memory resources, CPU, peripherals, information, etc.

My idea is to present it in college so my classmates and teachers know him (through an exhibition to be held in a month)

So I would appreciate any information about it that can give me for that purpose :D

Re: INFORMACION REQUERIDA

Posted: Tue Sep 18, 2012 1:51 pm
by DOSGuy
ciberyane wrote:The moderator team say me that is better i ask in this place, because is mor crowed :(
Then you need to post in English. A lot of people aren't going to look at the threads you created in General Discussion and Support because of the Spanish subject lines, defeating the purpose of posting in the more crowded forums.

You should also delete one of the two threads you created in Support since they're identical.

Re: Information required

Posted: Fri Sep 21, 2012 4:10 am
by b4dc0d3r
I think no one has replied because the answer is very complicated.

"Windows Internals" book, probably 4th or 5th edition, would be a great place to start. Or Charles Petzold's "Programming Windows" series. This gives a basic background, since the Intel architecture (x86 / x64) and the operating system have to work together for things like memory management and interrupts.

After that, when you know what to look for, you can download and look through the ReactOS source code to see where ReactOS may do something different from Windows. If you already know how Windows does it, all you need is to compare ReactOS way. But based on your question, it will take you more an 1 month to be able to explain it.

Re: Information required

Posted: Fri Sep 21, 2012 1:54 pm
by ciberyane
No have a longer time, (sorry im not really good in English), only need to know:
How the system allocates resources to processes?
if you could help me in this regard would greatly appreciate
need to present it in college in the mid of next month
the rest of the information I can get on my own
Please, could you do everything possible to help me? :oops: :cry:

Re: Information required

Posted: Fri Sep 21, 2012 2:58 pm
by vicmarcal
ciberyane wrote:No have a longer time, (sorry im not really good in English), only need to know:
How the system allocates resources to processes?
if you could help me in this regard would greatly appreciate
need to present it in college in the mid of next month
the rest of the information I can get on my own
Please, could you do everything possible to help me? :oops: :cry:
Ok.
Lets see.
First, ReactOS is a Windows opensource clone. That means that the Memory manager, Common Cache, and any processes related to threads, and resources are designed to be compatible with Windows ones.Or we would end with apps incompatibilities if we manage the memory in a total different way. Apps expects a Windows way, and we offer them a Windows-compatible way.
So basically at your question:"How does ReactOS manages resources?threads?and processed?" the answer is "The same way Windows does". At least from the designing point of view: HAL,Subsystems,MM,CC, Win32k,etc.
My question here is,no offence, then: "Do you know how Windows allocates and uses them?"
If so, you have there your answer. We don't use different mechanisms, but the same ones Windows 2003 server uses. As Windows code is not opensource and we can't neither look at it to preserve the legality, we implement as close as possible we know it behaves.Documentation(b4dc0d3r pointed you some nice books) and creating tests give us all the clues to "learn" how Windows does the internal work.


Your question, in the other hand is too wide as:Do you want us to show you how a Thread is created internally in ReactOS and destroyed?or How does ReactOS alloc memory in the Heap? or How do we page in and out our Memory? or How do we free a pointer?Each of these questions would need some pages of a book, not a fast reply neither a blogpost. So if you could point directly to the most interesting part for you, we can try to narrow the question and answer it.

Thanks for your intest!

Re: Information required

Posted: Sat Sep 22, 2012 1:52 pm
by ciberyane
First, thenk you for help me.
With your answer and I have a better idea of ​​how the OS
Now only need to know:
how a Thread is created internally in ReactOS and destroyed?
and
How does ReactOS alloc memory in the Heap?
I think that that would be enough to complete my presentation, I do not need anything too big, just a basic idea to develop it later, anyway I will consult the teacher about it.
Thanks again for your help
I wait for your answer :)

Re: Information required

Posted: Sat Sep 22, 2012 2:44 pm
by Angelus
Maybe you could take a look to some presentations and documents used in some important events (FOSDEM, Chemnitzer Linux Tage, Imaginatica,...) to present ReactOS. They could be useful to perform your presentation. Please, follow this link to take a look. I don't know if you must to ask for permission first to use them... but it's always welcome.

Re: Information required

Posted: Mon Sep 24, 2012 3:52 am
by vicmarcal
ciberyane wrote:First, thenk you for help me.
With your answer and I have a better idea of ​​how the OS
Now only need to know:
how a Thread is created internally in ReactOS and destroyed?
and
How does ReactOS alloc memory in the Heap?
I think that that would be enough to complete my presentation, I do not need anything too big, just a basic idea to develop it later, anyway I will consult the teacher about it.
Thanks again for your help
I wait for your answer :)

Creating a Thread

When a Windows app wants to create a new thread, it uses a winapi function named CreateThread().
In MSDN ( http://msdn.microsoft.com/en-us/library ... 85%29.aspx ) you can find "how" the app should call(send parameters to)the API to create a new thread.CreateThread is a function coded in Kernel32.DLL. Microsoft has coded it, so the App developer has just to "call" it and done.

As you can imagine, CreateThread is a function coded by Microsoft and its code is not public available.
So what does happen when the app calls CreateThread?Nobody "knows".We just can "guess" or "study" it in a clean way.
How?We know the objective of the API,the params the API uses, and even some errors that should return as explained in the MSDN doc. There are also books available about the NT system (as the Windows Internal Xth Edition). Add some tests(rostests and winetests)which consists basically to send the API a set of different params and checking the returned values.. and voila: Done!.

So when an app wants to Create a new thread, it calls the CreateThread() function. Really the app "doesnt mind*"if it is being run on top of ReactOS,Wine or Windows.The app just expects CreateThread() to perform its work correctly.
So basically ReactOS is enforced to create a compatible CreateThread() function which accepts the same number and type of parameters and in the same order.It has to be even placed inside the ReactOS Kernel32.dll.Summing up: A total and compatible ReactOS-Opensource CreateThread() function of the Microsoft-closed CreateThread() one.

The biggest difference is that ReactOS CreateThread() function is totally open. You can see the ReactOS CreateThread sourcecode here:
http://doxygen.reactos.org/d0/d85/dll_2 ... 98c1d.html

Doxygen is a really nice tool that can help you to follow how our CreateThread function is coded. In this case we call the CreateRemoteThread function and use its returned value.You can go as deeper as you want. Just click in the function names(they are links) and they will show you the code that implements them. You will end calling some NT functions as NtCreateThread or NtQueryInformationThread. You can follow these links to discover how they are implemented. The deeper you go, the more difficulty to follow they are. You are moving down,down,down...from user mode to kernel mode. Good luck there!


Allocating memory

There are different ways of allocating memory. GlobalAlloc, LocalAlloc, and HeapAlloc functions ultimately allocate memory from the same heap.
An interesting article about the differences among them and others ways of allocating memory can be found here:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

"GlobalAlloc and LocalAlloc are implemented as wrapper functions that call HeapAlloc using a handle to the process's default heap.", the MSDN doc says.
This gives an important clue to ReactOS devs to know the relationship among them.
In plain English this means that Microsoft GlobalAlloc() function calls HeapAlloc(), and so LocalAlloc() does.

Is,then, ReactOS GlobalAlloc() and ReactOS LocalAlloc() calling HeapAlloc() to perform the task?
Let's check ReactOS code thanks to Doxygen!

ReactOS LocalAlloc() source code can be found here: http://doxygen.reactos.org/db/dbb/winba ... 2db91d8926
As you can see LocalAlloc() seems to NOT be calling HeapAlloc() to perform the task through it, but it is calling RtlAllocateHeap to allocate the memory.

ReactOS GlobalAlloc() source code can be found here: http://doxygen.reactos.org/db/dbb/winba ... aa6f0db8db
As you can see GlobalAlloc() seems it is NOT calling HeapAlloc() to perform the task through it, but it is calling RtlAllocateHeap to allocate the memory.

Thanks to the MSDN reference, we have a Tip of how "internally" Microsoft is handling GlobalAlloc() and LocalAlloc(). But curioslly, ReactOS seems to not be using this tip in our ReactOS GlocalAlloc() and ReactOS LocalAlloc() implementation!!Remember: The tip says that Microsoft GlobalAlloc and LocalAlloc calls HeapAlloc() to perform the task!

Are we trying to reinvent the wheel?
Why don't we follow the same way Windows does thanks to that marvellous extrapieceofinfo?

Well..let's look CLOSER to our ReactOS functions!
What happens if we search HeapAlloc at Doxygen?
The following appears:
http://doxygen.reactos.org/d7/dff/lzexp ... e736e5be91
http://doxygen.reactos.org/d0/db5/dll_2 ... e736e5be91
http://doxygen.reactos.org/d0/db5/dll_2 ... e736e5be91

All those links have the same code:

Code: Select all

#define HeapAlloc   RtlAllocateHeap
Which means that HeapAlloc and RtlAllocateHeap are "sinonimous" most of the time.
In other words:
When ReactOS GlobalAlloc() calls RtlAllocateHeap really it is calling HeapAlloc, as MSDN says!
When ReactOS LocalAlloc() calls RtlAllocateHeap really it is calling HeapAlloc, as MSDN says!
So yes, we aren't reinventing the wheel and we are using this nice info ;)

RtlAllocateHeap is the base of those functions and can be found here:
http://doxygen.reactos.org/d8/d68/lib_2 ... 413ec0416d
Here you can find the internal functions that allocates a piece of memory in the heap. If you are brave enough you can try following how those functions are implemented by following the links. You will end in our lovely Memory Manager for sure :)
Deeper you go, the more difficult it is.


I don't know which is the supposed level of your presentation, but if you want to understand the deeper concepts about Virtual Memory,Memory manager, Heap and so on...I highly recommend you "Operating System concepts" book and "Windows Internals" one.

Hope this helps!

Re: Information required

Posted: Tue Sep 25, 2012 1:42 pm
by ciberyane
Thank you very much!!!
I think I have enough information to put together my report and prepare the exhibition
In a few days when i have completed the teacher took her for review.
If you notice anything. After presenting me tell you that this was
thank you again!!!

Re: Information required

Posted: Tue Sep 25, 2012 1:46 pm
by ciberyane
One last thing, this link does not work, you could send me the correct, please. http://doxygen.reactos.org/d0/d85/dll_2 ... 98c1d.html

Posted: Tue Sep 25, 2012 2:33 pm
by hto
I've fixed the link.

Re:

Posted: Wed Sep 26, 2012 11:02 pm
by vicmarcal
hto wrote:I've fixed the link.
Thanks hto!

Re: Information required

Posted: Tue Oct 02, 2012 1:32 pm
by ciberyane
this link dont work
http://doxygen.reactos.org/d0/d85/dll_2 ... 98c1d.html
please can you fix it???