OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:38 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: BareMetal OS v0.4.7
PostPosted: Wed May 12, 2010 1:04 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
The images should be the correct ones. Try refreshing the page. BareMetal OS - Architecture. It should have a date of May 5th.

v0.4.8 should be coming out in the next few weeks. Changes have been made to the multi-processor functions and the C library for the OS now supports the SMP calls as well.
Code:
// BareMetal compile
// gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -o csmp.o csmp.c
// gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -o libBareMetal.o libBareMetal.c
// ld -T app.ld -o csmp.app csmp.o libBareMetal.o


#include "libBareMetal.h"

void loop_a();
void loop_b();


int main()
{
   unsigned long var1=0, var2=0, local=0;

   b_smp_enqueue(&loop_a);         // Queue up some jobs
   b_smp_enqueue(&loop_b);         // The BareMetal OS queue is FIFO
   b_smp_enqueue(&loop_a);
   b_smp_enqueue(&loop_b);
   b_smp_enqueue(&loop_a);
   b_smp_enqueue(&loop_b);
   b_smp_enqueue(&loop_a);
   b_smp_enqueue(&loop_b);

   while (b_smp_queuelen() != 0)      // Check the length of the queue. If greater than 0 then try to run a queued job.
   {
      local = b_smp_dequeue();   // Grab a job from the queue. b_smp_dequeue returns the memory address of the code
      if (local != 0)         // If it was set to 0 then the queue was empty
         b_smp_run(local);   // Run the code
   }
   
   b_smp_wait();            // Wait for all CPU cores to finish
   b_print_string("end\n");

   return 0;
}


void loop_a()
{
   register unsigned long j,k;
   for(k=0; k<=665555; k++)
   {
      for(j=0; j<=100; j++){}
   }
   b_print_string("A is done\n");
}

void loop_b()
{
   register unsigned long j,k;
   for(k=0; k<=665555; k++)
   {
      for(j=0; j<=200; j++){}
   }
   b_print_string("B is done\n");
}

// EOF

The 4 instances of "loop_a" and "loop_b" will run in parallel (depending on the amount of CPU cores in the computer).

-Ian

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.4.7
PostPosted: Wed May 12, 2010 2:15 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 23, 2010 3:01 pm
Posts: 228
Location: Uppsala, Sweden
ReturnInfinity wrote:
The images should be the correct ones. Try refreshing the page. BareMetal OS - Architecture. It should have a date of May 5th.

Yup. That post was made on May 4th, and the image changed so I updated it with a quick edit somewhere ^^

Quote:
v0.4.8 should be coming out in the next few weeks. Changes have been made to the multi-processor functions and the C library for the OS now supports the SMP calls as well.
(...)
The 4 instances of "loop_a" and "loop_b" will run in parallel (depending on the amount of CPU cores in the computer).

-Ian

Great =D> Even though you might get some Elanore semaphore semaphore comments after displaying output from that ^^


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.4.7
PostPosted: Thu May 13, 2010 2:15 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
Sorry about that. I didn't notice that you edited your original post.

The "A", "B" stuff was just a proof of concept. The big thing now is to modify my Prime Numbers test program (a brute force test to check if a number is prime) to take advantage of multiple cores. I want to see the 2X speed increase using 2 CPU Cores instead of 1.

Here is the code so far: (Note: I haven't even attempted to compile it yet as it is unfinished)
Code:
// BareMetal compile
// gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -o primesmp.o primesmp.c -DBAREMETAL
// gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -o libBareMetal.o libBareMetal.c
// ld -T app.ld -o primesmp.app primesmp.o libBareMetal.o

// maxn = 300000  primes = 25997
// maxn = 400000  primes = 33860
// maxn = 1000000 primes = 78498


#include "libBareMetal.h"

void prime_process();


int main()
{
   register unsigned long maxn=400000, primes=0, local=0, processes=1;
   unsigned char tstring[25];
   unsigned long start, finish, k;

   start = b_get_timercounter();      // Grab the starting time

   for (k=0; k<=processes; k++)
   {
      b_smp_enqueue(&prime_process);
   }

   while (b_smp_queuelen() != 0)      // Check the length of the queue. If greater than 0 then try to run a queued job.
   {
      local = b_smp_dequeue();   // Grab a job from the queue. b_smp_dequeue returns the memory address of the code
      if (local != 0)         // If it was set to 0 then the queue was empty
         b_smp_run(local);   // Run the code
   }
   
   b_smp_wait();            // Wait for all CPU cores to finish

   finish = b_get_timercounter();      // Grab the finish time
   b_int_to_string(primes, tstring);   // Print the amount of primes for verification
   b_print_string(tstring);
   b_print_string(" in ");
   finish = (finish - start) / 8;
   b_int_to_string(finish, tstring);
   b_print_string(tstring);
   b_print_string(" seconds\n");

   return 0;
}


// 1 process   - 1: 1 2 3 ...
// 2 processes - 1: 1 3 5 ...   2: 2 4 6 ...
// 3 processes - 1: 1 4 7 ...   2: 2 5 8 ...   3: 3 6 9 ...
// 4 processes - 1: 1 5 9 ...   2: 2 6 10 ...   3: 3 7 11 ...   4: 4 8 12 ...
// And so on.

void prime_process()
{
   register unsigned long i, j, tprimes=0;

   i = 0;   // Calculate where this process starts

   for(; i<=maxn; i+=processes)
   {
      for(j=2; j<=i-1; j++)
      {
         if(i%j==0) break; //Number is divisble by some other number. So break out
      }
      if(i==j)
      {
         tprimes = tprimes + 1;
      }
   } //Continue loop up to max number
   
   // add tprimes to primes
   primes = primes + tprimes;
}

// EOF

This is a modification of the prime.c program I have been using to benchmark performance between Linux and BareMetal OS running on the same physical hardware.

-Ian

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.4.7
PostPosted: Wed May 19, 2010 8:58 am 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
Good news! Calculations in C with multiple CPU cores works correctly!

The code in the last post did work with a few alterations but there was a logic error. The prime_process() function would check even numbers as well. This would mean there was no performance increase using two processes on a dual-core system (One core would check the odd numbers and would take a long time and one core would check the even numbers and complete quickly). Dividing the workload in 4 worked correctly on a the dual-core system.

The new program only checks odd numbers and works correctly with two processes.
Code:
// BareMetal compile
// gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -o primesmp.o primesmp.c
// gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -o libBareMetal.o libBareMetal.c
// ld -T app.ld -o primesmp.app primesmp.o libBareMetal.o

// maxn = 10000   primes = 1229
// maxn = 100000  primes = 9592
// maxn = 300000  primes = 25997
// maxn = 400000  primes = 33860
// maxn = 1000000 primes = 78498


#include "libBareMetal.h"

void prime_process();

// primes is set to 1 since we don't calculate for '2' as it is a known prime number
unsigned long maxn=400000, primes=1, local=0, lock=0, process_stage=0, processes=8;
unsigned char tstring[25];

int main()
{
   unsigned long start, finish, k;
   
   process_stage = processes;

   start = b_get_timercounter();      // Grab the starting time

// Spawn the worker processes
   for (k=0; k<processes; k++)
   {
      b_smp_enqueue(&prime_process);
   }

// Attempt to run a process on this CPU Core
   while (b_smp_queuelen() != 0)      // Check the length of the queue. If greater than 0 then try to run a queued job.
   {
      local = b_smp_dequeue();   // Grab a job from the queue. b_smp_dequeue returns the memory address of the code
      if (local != 0)         // If it was set to 0 then the queue was empty
         b_smp_run(local);   // Run the code
   }

// No more jobs in the queue
   b_smp_wait();            // Wait for all CPU cores to finish

   finish = b_get_timercounter();      // Grab the finish time

// Print the results
   b_int_to_string(primes, tstring);   // Print the amount of primes for verification
   b_print_string(tstring);
   b_print_string(" in ");
   finish = (finish - start) / 8;
   b_int_to_string(finish, tstring);
   b_print_string(tstring);
   b_print_string(" seconds\n");

   return 0;
}


// prime_process() only works on odd numbers.
// The only even prime number is 2. All other even numbers can be divided by 2.
// 1 process   1: 3 5 7 ...
// 2 processes   1: 3 7 11 ...   2: 5 9 13 ...
// 3 processes   1: 3 9 15 ...   2: 5 11 17 ...   3: 7 13 19 ...
// 4 processes   1: 3 11 19 ...   2: 5 13 21 ...   3: 7 15 23 ...   4: 9 17 25...
// And so on.

void prime_process()
{
   register unsigned long h, i, j, tprimes=0;

   // Lock process_stage, copy it to local var, subtract 1 from process_stage, unlock it.
   os_smp_lock(lock);
   i = process_stage;
   if (i == 1)
   {
      i = 3;      // process 1 starts at 3
   }
   else
   {
      i = (i * 2) + 1;   // process 2 starts at 5 (2 * 2 + 1), process 3 starts at 7 (3 * 2 + 1)
   }
   process_stage--;
   os_smp_unlock(lock);

   h = processes * 2;

   // Process
   for(; i<=maxn; i+=h)
   {
      for(j=2; j<=i-1; j++)
      {
         if(i%j==0) break; // Number is divisble by some other number. So break out
      }
      if(i==j)
      {
         tprimes = tprimes + 1;
      }
   } // Continue loop up to max number

   // Add tprimes to primes.
   os_smp_lock(lock);
   primes = primes + tprimes;
   os_smp_unlock(lock);
}

// EOF

Application run-time test on a dual-core system:
1 process: 118 seconds
2 processes: 59 seconds
4 processes: 59 seconds
8 processes: 60 seconds
16 processes: 60 seconds

Version 0.4.8 will come out in the next few weeks. Currently working on command line argument passing to a C programs.

Also, I need a computer with more cores :P

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.4.7
PostPosted: Thu May 20, 2010 9:00 pm 
Offline
Member
Member
User avatar

Joined: Wed Mar 05, 2008 12:52 am
Posts: 142
ReturnInfinity wrote:
Also, I need a computer with more cores

Why not just emulate it? Sure, there's not going to be a performance increase, but it works as a proof of concept.


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.4.7
PostPosted: Fri May 21, 2010 12:44 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
As a proof of concept it does work. I have successfully emulated 64 CPUs under QEMU. QEMU (0.12.3) seems to only be able to emulate up to 91 CPU's but BareMetal OS should support 256.

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: BareMetal OS v0.4.8
PostPosted: Tue Jul 13, 2010 2:04 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
Version 0.4.8 has been released. Documentation updates, bug fixes, additions to the C library, etc.

Included in the distribution is a program called 'primesmp'. This C program uses all of the available processors in the system to detect prime numbers (via brute force). The application performance scales with the amount of CPU cores in the system.

On a quad-core i3 @ 2.66GHz running PrimeSMP to calculate all primes between 1 and 400000:
1 Core - 46 seconds
2 Cores - 23 seconds
4 Cores - 12 seconds

Also by using the latest version of Pure64 we now support HyperThreading. From our testing it increases system performance by about 20%.Tests were done with an Intel D945GCLF2 board - Atom 330 CPU (Dual Core 1.6GHz), 2GiB RAM

Hyper-threading off : 269 seconds
Hyper-threading on : 223 seconds

http://www.returninfinity.com/baremetal.html

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.4.9
PostPosted: Wed Sep 15, 2010 7:36 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
BareMetal OS v0.4.9 has been released today. The OS now supports Ethernet access via the Realtek 8139 chipset. Functions for memory management (alloc/free) have also been added.

Work is also being done on a full C library here: http://code.google.com/p/barelibc/

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.5.0
PostPosted: Tue Feb 15, 2011 12:25 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
BareMetal OS v0.5.0 was released today. This is mainly a maintenance release.

The C library has been updated to support the latest versions of CGG and binutils.

Video performance has been improved.

Looking forward to v0.6.0: DMA access for Hard Drives, an improved C library, and some basic TCP/IP support.

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.5.1
PostPosted: Mon May 16, 2011 11:41 am 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
BareMetal OS v0.5.1 was released today. This is a maintenance and feature release.

The major change is the network hardware support. BareMetal OS now supports the Intel Pro/1000 family of Ethernet chipsets (anything i8254x-based) as well as the Realtek 8169-based family (8169, 8110, 8168, and 8111). BareMetal can be run under VirtualBox with full network support (Great for testing).

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.5.2
PostPosted: Wed Jul 06, 2011 11:45 am 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
BareMetal OS v0.5.2 was released today.

The Newlib C library has been ported to BareMetal OS so it is now possible to compile apps that use the standard ANSI C calls like printf(). This makes it a bit easier to compile existing code for the new system. File calls within Newlib have not been coded for yet so it is limited to STDIN, STDOUT, and STDERR.

ARP support has also been added for the IPv4 stack that is currently in progress.

A 64-bit BASIC interpreter as well as a Brainf*ck interpreter were also added as demo applications.

-Ian

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.5.2
PostPosted: Fri Jul 08, 2011 8:40 am 
Offline

Joined: Fri Jul 08, 2011 7:56 am
Posts: 1
Before you continue any further on BareMetal OS, go write an application for Android. Something with a couple of 'Activity's is sufficient. Where you are headed really fast is just going to land you where every OS for Intel chips has landed. We need a completely different paradigm of thought for multi-core and, you started on the right track, but dropping in a Standard C library indicates you may be losing your way - plus the Standard library isn't exactly tiny. An Android 'Activity' is a self-contained unit of logic. As a generalized simplification, only one Activity is running at one time. Think of that as similar to the "one task per core" objective you have in mind. IMO, you need to do something similar for C before continuing with Bare Metal OS. From a C perspective, the Android way of doing things would essentially be multiple 'main()'s inside a single "program" - that is, multiple entry points. Multi-core programming requires a completely different way of thinking from traditional techniques. C is a one-task pony that was designed ages ago and still doesn't understand what multithreading and multi-core are. Shoehorning the current design paradigm of "each program has a single entry-point" into a multi-core environment is going to create a mess. To fully leverage multi-core, C itself needs to be changed.

Just a thought - something to chew on. Obviously, anyone looking at BareMetal in the first place is going to have serious processing needs. But let's say, for instance, this gets to be like Linux where it takes off and spawns a complete end-user OS with a large fan base. That's how far ahead I'm thinking here. You haven't fundamentally changed anything and therefore this will likely just be something obscure only used by a limited number of people...projects like that tend to die slowly. They're fun and neat, but that's it. This project has potential to be a serious contender to everything out there.


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.5.2
PostPosted: Fri Jul 08, 2011 10:16 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
silversmith wrote:
Before you continue any further on BareMetal OS, go write an application for Android.

I guess his project is an OS but not application, so where did the Android came in?

Quote:
Multi-core programming requires a completely different way of thinking from traditional techniques. C is a one-task pony that was designed ages ago and still doesn't understand what multithreading and multi-core are.

Check pthread(and its variants) for traditional parallel computing, and perhaps OpenMP. Yes they works in C as well.

Quote:
the current design paradigm of "each program has a single entry-point" into a multi-core environment is going to create a mess. To fully leverage multi-core, C itself needs to be changed.

It really does not matter if your program starts as single entry point and then create threads.
If you really want to starts with multiple entry point you can create them in startup code, for example hide them within process creation stub, or CRT0.o

The real issue is that application does not know about system loading and cannot do load balancing without the help of information from kernel scheduler, however, this issue is irrelevant to programming language.

Quote:
You haven't fundamentally changed anything and therefore this will likely just be something obscure only used by a limited number of people...projects like that tend to die slowly. They're fun and neat, but that's it. This project has potential to be a serious contender to everything out there.

IMO if you plan to make a successful OS, people suggests you need good marketing instead of anything significant in technology. Well, I have not managed to make a successful OS so I'm really not sure on it. For me, fun and neat would be the ultimate goal for now.


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.5.2
PostPosted: Fri Jul 08, 2011 3:52 pm 
Offline
Member
Member

Joined: Mon Dec 21, 2009 6:03 pm
Posts: 164
I think BareMetal does exactly what its set out to do.

Don't get me wrong, I agree with all your points. We do need a change of paradigm, a change of language, workflow, understanding etc.. but that really is something that needs heavy research into.

Microkernels are now in the 3rd? generation.. and they have hit road blocks in understanding in some way. I dont fully understand the problems, but I personally see that to create an operating system that is "better" than our current ways just isnt going to happen any time soon and most likely by anyone of us.

Mike


Top
 Profile  
 
 Post subject: Re: BareMetal OS v0.5.3
PostPosted: Thu Feb 23, 2012 1:59 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
BareMetal OS v0.5.3 was released today.

Uses the latest Pure64 for IO-APIC support.
Newlib v1.20 supported.
Added an 'ipconfig' utility for setting up an IP address.
Basic ARP and ICMP support so it responds to ping.

Next release will hopefully have a full IP stack.

-Ian

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 16 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