OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Questions[virtual machine architecture]-[C Modular prog]
PostPosted: Mon Apr 08, 2019 4:05 pm 
Offline

Joined: Mon Apr 08, 2019 3:39 pm
Posts: 1
Hi,

I 'd Like to ask few questions ,

1) for programming on physical hardware the architecture may vary , but if I want a standard non changeable
architecture I can learn on virtual machines like vmware or virtualbox ..etc , now my questions where could
I get information about the architecture of that generic virtual machine like Registers and I/O map and
Equivalent Block diagram also what adds complexity is that new architectures use north bridge, south bridge
parallel processors and cores , I think books like The Intel Microprocessors (8th Edition) by Barry B. Brey
are good for knowing concepts but the block diagrams and architectures is older than today's real machines
do you have a book or material recommendations or what I will encounter as programmer on virtual machines
is included in such book

2) I'd Like to understand about the ABI and how to write Modular C-code and make libraries , I know C programming
but didn't have such experience to write code in different files compile separately and make libraries and link them
If you have any material recommendations also here or how to start understanding what is ABI and what enforces it,
it will be helpful

3) Also I have a last Question in my mind when I write a C program , functions call a function which call a function etc till
atomic function , by atomic i mean that we don't go infinity for calling functions and thos level of atomic functions can be
executed , how those functions are written , are written in assembly directly ?

4) Do you have any recommendation about material for tool chain course that willl answer question 2 and 3

I have searched the web for those questions I am confused about many times and found too many results but
confused where to start

thanks


Top
 Profile  
 
 Post subject: Re: Questions[virtual machine architecture]-[C Modular prog]
PostPosted: Mon Apr 08, 2019 8:34 pm 
Offline
Member
Member

Joined: Fri Jun 28, 2013 1:48 am
Posts: 65
"Architecture" usually means something like x86, ARM, SPARC, etc. Virtual Machines also have architecture. VMware and VirtualBox are just emulators of x86 architecture computers. So just pick one architecture you are most familiar with, or the architecture of your current computer (most likely x86_64).

_________________
Reinventing the Wheel, code: https://github.com/songziming/wheel


Top
 Profile  
 
 Post subject: Re: Questions[virtual machine architecture]-[C Modular prog]
PostPosted: Tue Apr 09, 2019 2:37 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5143
AbdAllahTalaat wrote:
1)

Most virtual machines support the i440FX northbridge and PIIX3 southbridge, or chips in the same family (e.g. i440BX and PIIX4). There is no better place to learn about those than Intel's datasheets. You'll have to read your virtual machine's manual to see exactly which chipset it implements.

AbdAllahTalaat wrote:
2)

The ABI is a standard that says how to generate a binary that can be linked with other binaries to produce a working program. For example, Linux software uses the System V ABI.

I don't have any good references on writing modular code, or how to link it. Perhaps you should look for beginner C programming guides.

AbdAllahTalaat wrote:
3)

Functions can be written purely in C. If you're talking about things like operators, those are written in the compiler's intermediate language. The intermediate language can be translated to assembly, but most compilers will optimize it first.

AbdAllahTalaat wrote:
4)

I've learned a lot from reading the GCC documentation, but I wouldn't recommend starting there.


Top
 Profile  
 
 Post subject: Re: Questions[virtual machine architecture]-[C Modular prog]
PostPosted: Tue Apr 09, 2019 2:37 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
Hi and welcome,

AbdAllahTalaat wrote:
Hi,

I 'd Like to ask few questions ,

1) for programming on physical hardware the architecture may vary , but if I want a standard non changeable
architecture I can learn on virtual machines like vmware or virtualbox ..etc ,
All hardware are different. It is the OS' duty to hide that fact and provide a consistent interface to the user space applications. Virtual machines are different too, and you can configure them (so they are "changeable hardware" too).

Quote:
now my questions where could
I get information about the architecture of that generic virtual machine like Registers and I/O map and
Start at the wiki. Do you see the "Got a question? Search this first!" link in the navbar? Finding the documentation on your own is part of the fun. But the wiki has links to the specs if you feel not up to it.

Quote:
Equivalent Block diagram also what adds complexity is that new architectures use north bridge, south bridge
parallel processors and cores , I think books like The Intel Microprocessors (8th Edition) by Barry B. Brey
are good for knowing concepts but the block diagrams and architectures is older than today's real machines
do you have a book or material recommendations or what I will encounter as programmer on virtual machines
is included in such book
Except for some special devices (qemu video driver, ARM semihosting, bochs E9 debug console hack etc.) there's none. I don't think there's such a book. You have to figure out which devices the emulator simulates, and write code for that. If you then boot your OS on a real hardware which happens to have the same devices, it will work on that too (hopefully).

Quote:
2) I'd Like to understand about the ABI and how to write Modular C-code and make libraries , I know C programming
but didn't have such experience to write code in different files compile separately and make libraries and link them
If you have any material recommendations also here or how to start understanding what is ABI and what enforces it,
it will be helpful
Again, check our wiki. There're tons on information on this topic, mostly SysV ABI related (ELF), which is good for the Open Source world (technically ELF is for everything that's not Windows). If you want to go on the PE road, MSDN is your best source of information (and I have to tell you that Microsoft documentations are sometimes incomplete, but what's in there, that's surprisingly good and detailed).

Quote:
3) Also I have a last Question in my mind when I write a C program , functions call a function which call a function etc till
atomic function , by atomic i mean that we don't go infinity for calling functions and thos level of atomic functions can be
executed , how those functions are written , are written in assembly directly ?
I feel a little disturbance in the force here. First, atomic means the function is uninterruptible and exclusive, meaning only one CPU core can execute it at any given time. Functions that are not calling other funtions are called leafs. This designation has nothing to do with C or Assembly. You can write atomic functions in C (using mutexes or even inline assembly for example), and Assembly functions can call other functions. Some architecture has special C attributes which guarantees function atomiticy, while others require special assembly mnemonics for that.

Quote:
4) Do you have any recommendation about material for tool chain course that willl answer question 2 and 3

I have searched the web for those questions I am confused about many times and found too many results but
confused where to start
Yes, start by reading the wiki.
About recommendations, I'd recommend to use SysV ABI and ELF, as they are Open Source and there are so many information and tutorials about them. GNU toolchain is quite common, but recently LLVM is gaining on it. For GNU, you'll have to compile your own toolchain (gcc cross-compiler and ld cross-linker at a minimum), while LLVM tool chain (Clang compiler and lld linker) is by definition a cross-compiler, so it's easier to start with. GNU toolchain has been around for decades, so it's a bit bloated but very well tested; LLVM on the other hand is well-thought and legacy-free. Despite of this, both have bugs and neither support the full C standard, only partialy.

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: Questions[virtual machine architecture]-[C Modular prog]
PostPosted: Tue Apr 09, 2019 6:33 am 
Offline
Member
Member

Joined: Thu Jul 03, 2014 5:18 am
Posts: 84
Location: The Netherlands
Hi,

    1. A VM emulates existing hardware. So if you want information about the hardware it emulates, you need to find the documentation about the hardware. It should be enough for your purposes.
    2. You don't need information about the ABI in order to understand how to compile multiple files into a binary.
    3. I really struggle to understand your question here. It would be wise not to redefine atomicity, which is about concurrency, not about infinity.
    4. IMHO, these are concepts not specific to osdev, so I advise you to learn more about C and low-level programming. You are probably confused because you have not yet mastered a lot of basic fundamental material.

_________________
My blog: http://www.rivencove.com/


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot], SemrushBot [Bot] and 107 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