Welcome, Guest. Please login or register.

Author Topic: Why is SMT (multicore) support hard for Amiga OS?  (Read 20523 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #29 on: June 27, 2010, 02:25:38 PM »
Quote from: bloodline;567558
Ergo, we no longer would be using AmigaOS! :)


That boat already sailed with OS4, AROS and MOS ;)
int p; // A
 

Offline Amiga_Nut

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 926
    • Show only replies by Amiga_Nut
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #30 on: June 27, 2010, 04:03:06 PM »
Yes but in classic Amiga + PPC card systems you are killing one processor to a allow the other to function. If you have to kill the 680x0 CPU for the 603/604 PPC to execute then how is that multi processor supporting OS?

This is one of the big reasons why PPC didn't sell to us, it was a competition between two kludge's to an OS that badly needed help from Commodore for the PPC era....who had decided to blow their last load on some crappy crippled CD console instead....
 

Offline tone007

Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #31 on: June 27, 2010, 04:24:33 PM »
Quote from: Amiga_Nut;567575
Yes but in classic Amiga + PPC card systems you are killing one processor to a allow the other to function. If you have to kill the 680x0 CPU for the 603/604 PPC to execute then how is that multi processor supporting OS?


It isn't, no one was saying it is, and you're headed off-topic.

This thread is about new implementations of OS4 on new hardware that can support SMP (which the example you've given, even if both processors were used simultaneously, is not an example of.)  OS4 on Classic is just about dead and buried.
3 Commodore file cabinets, 2 Commodore USB turntables, 1 AmigaWorld beer mug
Alienware M14x i7 laptop running AmigaForever
 

Offline Fats

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 672
    • Show only replies by Fats
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #32 on: June 27, 2010, 04:27:57 PM »
Quote from: bloodline;567411
@Bif

This is just another case of one simple design decision, to share memory pointers for a bit of extra speed, coming back to bite us 25 years later :(


I disagree, I'm a big fan of message passing by pointer passing; it is one of the reasons I stay with AROS and did not delve into something like DragonFlyBSD.
IMHO, the bad design decision was that user programs were allowed to call a system wide lock. It is like the linux BKL (bug kernel lock) but then an order of magnitude more difficult as it is also used by user programs.

greets,
Staf.
Trust me...                                              I know what I\'m doing
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #33 on: June 27, 2010, 04:49:04 PM »
Quote from: Amiga_Nut;567575
Yes but in classic Amiga + PPC card systems you are killing one processor to a allow the other to function. If you have to kill the 680x0 CPU for the 603/604 PPC to execute then how is that multi processor supporting OS?

Wrong. You have clearly misunderstood how the system worked. Nothing is "killed off", certainly not the CPU.

Your "virtual task" has just moved from 68K to PPC (or vice versa). In practise, your physical 680x0 task goes to sleep whilst the mirror PPC one is running (and vice versa when it returns).

Each processor is running a pre-emptive multitasking kernel. When either the currently active 68K or PPC task goes to sleep, the corresponding processor is immediately able to continue running a different task when the kernel next runs it's scheduling routine.
« Last Edit: June 27, 2010, 04:51:18 PM by Karlos »
int p; // A
 

Offline BifTopic starter

  • Full Member
  • ***
  • Join Date: Aug 2009
  • Posts: 124
    • Show only replies by Bif
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #34 on: June 28, 2010, 06:41:12 PM »
Lots of interesting stuff here, I am learning a lot just sitting back and watching this for a bit =).

Quote from: amigadave;567402
@Bif,

First off if it already has not been done, allow me to welcome you to the Amiga.org forums.  It is always good to see Amiga users with programming experience/talent return to the Amiga community, as we are woefully short on competent programmers (at least compared to the number of Amiga programmers there once were).

Lastly, even if it proves to be impossible, or impractical to implement support for multiple core CPU's within AmigaOS4.x/MorphOS2.x/AROS, I hope that you will find the time to do some other Amiga programming in the future and that what ever code you do write will be able to be compiled for all three OS'es mentioned above.


Thanks amigadave =). I am keen on a number of potential Amiga projects so hope to help out at some point. The multicore thing was just the only real mystery gnawing at me. When i used the Amiga back in the early 90s my pet peeve was the lack of memory protection and virtual memory that caused the system or apps to go down in flames (multicore wasn't an issue back then =)). So my number one desire is to see Amiga OS get some modern OS conveniences.

In all honesty I'll probably only be doing AROS work because the others are simply impractical for me, at least at this time. I will be cognizant of maintaining compatibility with everything though and I'm an open source kind of guy so someone else can recompile/patch. As a habit I like to write cross-platform code where possible in case I want what I am working on running on something totally different.

Quote from: bloodline;567411
@Bif

As Fats (or Staf as we know him on the AROS list), has pointed out, AmigaOS shares resources... Ok, the Forbid() problem is a big one, but now think about HOW the amiga shares resources. It's all pointer passing, you basically have no idea which task/process is using what memory... if you need atomic access to a resouce you NEED to stop all tasks/processes that are currently running on the system...

This is just another case of one simple design decision, to share memory pointers for a bit of extra speed, coming back to bite us 25 years later :(


That sounds plausible. However, how does this even work on a single core system? Isn't access to these resources synchronized across tasks/threads already? Otherwise how do you know if whatever you have written to various memory locations is not in a half baked state when the other thread consuming it or also writing to it wakes up? Does the kernel have some intelligence when swapping tasks to ensure this somehow? I can't imagine that. I'd think this must be what the Forbid()/Permit() type of thing are exactly for if there is no other synchronization mechanism involved in these shared memory locations? I would think the kernel would not allow a task with a Forbid() in place to be swapped for this reason.

I think that multi-threaded programs need to live under pretty much the same constraints on single core systems vs. multicore systems (except for cache coherency issues). The difference when going multicore is that you hit multi-threading bugs much faster because it's all running at the same time. On single core systems you only run into potential problems during a context switch.

Karlos provided a lot of useful information in regards to memory/cache coherency, indeed I think I share the view that these days multicore is fairly evolved and not as challenging as it once was.

Quote from: NorthWay;567447
The quick and dirty answer?

Way too many programmers (including the C= library ones) have been too quick and dirty.
Forbid()/Permit() is actually documented as a macro in the official includes. Same with Disable()/Enable().
That means you can't insert your fix in the jumptables and expect all uses of the Big Lock to get caught. Possible solutions are to do Enforcer style ExecBase hacks to mmu-track the lock or interrupt register.

From there on in I bet there are many more pitfalls.


Fair enough, but at this point I think we are looking at next-gen amiga systems, and I don't think an application recompile is too unreasonable if required. Is the AROS Forbid() a macro for example? If it's 68k apps then I don't think we care too much about them, they can all run on one CPU or under emulation if need be or whatever. I guess I can see it being a problem where you let 68k apps call directly into the OS kernel that is running PPC/X86 if you can't trap that.

Quote from: bloodline;567457
Again, I would never point to the impossibility of SMP in Amiga systems, I only suggest that it serves no purpose. What use is two cores when they will run slower than one?


This is something I struggled with in my day job for years. I think I have a pretty good idea of what kind of code benefits from multicore and what doesn't. This is an argument that is often thrown up to easily avoid the problem of multicore coding. Indeed some code is bloody impossible to make multicore. In the case of an OS, I see it as a facilitator of letting programs go multicore. The OS itself shouldn't be using up all the CPU, your apps should. A well written app should not be banging the OS like crazy. In this context your app shouldn't even be aware that is running on one particular core of the CPU, unless you multi-thread it to take advantage of multiple cores (a good idea if it can be done). In this case the app is pretty much running on the bare metal and the OS shouldn't be getting in the way much. There is no excuse for slow downs at this point except for general memory bandwidth limits that all CPUs will suffer on all OSs, but are well known.

I think you can probably say one thing is true, a multicore friendly kernel will probably run a bit slower on a single core CPU because of the extra code involved. However, I wouldn't think very much slower. No idea at all really, but maybe less than 1%.

I can only see a multicore kernel slowing things down if it needs to be full of crazy hacks like MMU traps and the like to make some arcane thing work.

Multicore is here to stay and becoming more prevalent every day. For AROS/X86 it's hard to find a single core system, and now with the X1000 there is no excuse not to waste that second core.

Quote from: Zac67;567517
Real SMP however makes no assumptions to where the code is actually running - this implies to the OS itself as well. Apart from the Forbid/Permit workarounds, you're looking at a complete redesign of the kernel. Remember the Windows 95/98/ME line? These relatively simple kernel designs stood no chance of running SMP, so MS didn't even bother trying.


Quote from: dammy;567547
That's my vote. :-)  We need something modern that has the spirit of AOS but that would be a massive undertaking requiring a significant size dev team and funding for that clean sheet of paper.


I'm not sure if adding multicore calls for a complete redesign of the kernel or not? Honestly I don't know the answer to this, I've never even perused any kernel code. I'm out of my element here. However, in the W95->NT case, I think there was a lot more going on there than just multicore. The NT kernel was built from the ground up with security and stability in mind. I think that probably took more precedence for its selection that just multicore. In my crude estimation, bringing AmigaOS up to the NT standard or stability and security would be a far larger undertaking than adding multicore.

In the end I think Amiga OS probably needs a hugely revamped kernel if we want to get all the modern stuff, and I'm not against that. But I'm thinking multicore alone may not require that.
 

Offline AmigoHD

  • Newbie
  • *
  • Join Date: Jun 2010
  • Posts: 1
    • Show only replies by AmigoHD
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #35 on: June 28, 2010, 07:10:56 PM »
I now read the whole 3 pages and still I'm asking myself why AOS should need multicore-support.
I guess there are lots of more important things to be done. First of all we need software. We need an up-to-date office solution, maybe a java runtime environment. Browsers we need too - thx to OWB and Timberwolf there are good solutions on it's way.
When we have lots of good, new and modern software we can talk about raw cpu power.
But without software which would use it, smp is useless and a waste of time to implement it IMHO.

Sorry for this offtopic answer (as my first answer ever here :-)), but it's just true.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #36 on: June 28, 2010, 07:21:40 PM »
Quote from: AmigoHD;567813
But without software which would use it, smp is useless and a waste of time to implement it IMHO.

Sorry for this offtopic answer (as my first answer ever here :-)), but it's just true.


All software can take advantage of SMP, it doesn't have to be written for it. All you have to do is run more than one such software application at once to get the benefit of having additional processor cores.

Beyond that, any application that has multiple threads will also potentially benefit if it ever has two threads that are ready to run. Some apps create lower priority background threads for various maintenance purposes that would normally only get the chance to run when nothing more important was using the CPU. In a true SMP system, they'd not be held back.

Lastly, remember that on AmigaOS, for example, the user interface layout often happens in a different thread than the application itself (not so sure about MUI there).
int p; // A
 

Offline kolla

Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #37 on: June 28, 2010, 07:26:09 PM »
Quote from: AmigoHD;567813
I now read the whole 3 pages and still I'm asking myself why AOS should need multicore-support.
I guess there are lots of more important things to be done. First of all we need software.


If you write software first, then all this software would most likely need to be ported afterwards when you change the OS. Most Amiga software is already written, it's the OS that really lags behind, in just about all areas.
B5D6A1D019D5D45BCC56F4782AC220D8B3E2A6CC
---
A3000/060CSPPC+CVPPC/128MB + 256MB BigRAM/Deneb USB
A4000/CS060/Mediator4000Di/Voodoo5/128MB
A1200/Blz1260/IndyAGA/192MB
A1200/Blz1260/64MB
A1200/Blz1230III/32MB
A1200/ACA1221
A600/V600v2/Subway USB
A600/Apollo630/32MB
A600/A6095
CD32/SX32/32MB/Plipbox
CD32/TF328
A500/V500v2
A500/MTec520
CDTV
MiSTer, MiST, FleaFPGAs and original Minimig
Peg1, SAM440 and Mac minis with MorphOS
 

Offline kolla

Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #38 on: June 28, 2010, 07:27:57 PM »
Quote from: Karlos;567817
All software can take advantage of SMP, it doesn't have to be written for it.


Oh, but it has to be ported to this new AmigaOS that does SMP :)
B5D6A1D019D5D45BCC56F4782AC220D8B3E2A6CC
---
A3000/060CSPPC+CVPPC/128MB + 256MB BigRAM/Deneb USB
A4000/CS060/Mediator4000Di/Voodoo5/128MB
A1200/Blz1260/IndyAGA/192MB
A1200/Blz1260/64MB
A1200/Blz1230III/32MB
A1200/ACA1221
A600/V600v2/Subway USB
A600/Apollo630/32MB
A600/A6095
CD32/SX32/32MB/Plipbox
CD32/TF328
A500/V500v2
A500/MTec520
CDTV
MiSTer, MiST, FleaFPGAs and original Minimig
Peg1, SAM440 and Mac minis with MorphOS
 

Offline trekiej

Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #39 on: June 28, 2010, 07:44:02 PM »
@ bif
I hope this is not off topic.
I understand that the Amiga is an Asymetric type machine.
Is it possible to make a library to run software on another core?
If I was running an MPEG decoder, could it be decoded on another core?
I feel like there would be problems similar to what has to be taken care of in an SMP system.
I guess it would make the other cores a co-processor of a sort.
Wake it up, send a small program, get results and then put it to sleep.
I am very new to this sort of thing, I am not for sure what is possible.
Thanks.

http://en.wikipedia.org/wiki/Asymmetric_multiprocessing
« Last Edit: June 28, 2010, 07:52:16 PM by trekiej »
Amiga 2000 Forever :)
Welcome to the Planar System.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #40 on: June 28, 2010, 07:46:51 PM »
Quote from: trekiej;567829
I hope this is not off topic.
I understand that the Amiga is an Asymetric type machine.
Is it possible to make a library to run software on another core?
If I was running an MPEG decoder, could it be decoded on another core?


You do that every time you use a ppc datatype in OS3.x or run any application that supports WarpOS/PowerUp.
int p; // A
 

Offline trekiej

Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #41 on: June 28, 2010, 07:54:04 PM »
Unfortunatley, I do not think this happens to help programs run any faster or be con-current.
Amiga 2000 Forever :)
Welcome to the Planar System.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #42 on: June 28, 2010, 08:02:36 PM »
Quote from: trekiej;567832
Unfortunatley, I do not think this happens to help programs run any faster or be con-current.

Nope, offloading image decoding to a CPU with 9.6x the clockspeed of your 68040 makes nooo difference ;)

You should read further up the thread to understand how WOS works. The 680x0 is not idle when the PPC is called to do a task, it is instead busy running some other application's code. The reason is that the calling 68K task goes to sleep. The moment the presently active task goes to sleep, exec it free to switch it out for a task that is ready to run at the next scheduling interrupt.

There seems to be this idea that either the 680x0 is running, or the PPC is running. This is not the case. Both CPUs are running at the same time and only when they both attempt to access memory at the same moment is one physically blocked by another.

What is true is that a synchronous PPC <-> 68K call puts the calling thread to sleep and waits untill the callee's thread has finished executing the code.

There are also asynchronous calls but due to the complexity of using them, not many applications do.
int p; // A
 

Offline trekiej

Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #43 on: June 28, 2010, 08:22:12 PM »
Sorry, I should have related to AROS or AOS4.1 instead.
I think that is why some ppc cards had a video card attached, if I remember correctly.
It sounds like it could talk to the video card, hopefuly, without much interuption.
I do not know much about the ppc/68k accel. cards. It has been a long time since I have read anything about them. If the ppc has its own memory and video out, performance should be much better.
« Last Edit: June 28, 2010, 08:23:50 PM by trekiej »
Amiga 2000 Forever :)
Welcome to the Planar System.
 

Offline NorthWay

  • Full Member
  • ***
  • Join Date: Jun 2003
  • Posts: 209
    • Show only replies by NorthWay
Re: Why is SMT (multicore) support hard for Amiga OS?
« Reply #44 from previous page: June 28, 2010, 10:12:56 PM »
Quote from: Bif;567806
Fair enough, but at this point I think we are looking at next-gen amiga systems, and I don't think an application recompile is too unreasonable if required.

Let me rephrase what I said:
The Forbid/Permit semaphore is a publicly readable and writeable kernel structure.
You are free to change the definition of how the OS works, but then you are on your own. AROS (very sensibly (IMNSHO)) decided to take 3.1 with warts and all and implement that first. When they are 100% done you can add New Stuff.