OS without MMU

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: OS without MMU

Post by gerryg400 »

99% code is written under time constraint , c code is buggy and takes a lot longer for very little performance gain.

Implement an algortihm in 2 hours i bet Ocml will be 10* faster on 10+ cores , c# will be faster and with C your still dealing with some seg fault , or looking up some threading.
What evidence do you have for this. Think about some of the projects you have been involved in. How, when the actual coding phase of a correctly engineered software project represents barely 20% of the project time, can you can blame the programming language for the bugs you have. Surely the insane scheduling, scrappy requirements gathering, non-existent system engineering, and poor testing methodology are the cause of the majority of bugs. C is not to blame. And a c program that seg-faults is no worse than a java program that gives the wrong answer.

- gerryg400
If a trainstation is where trains stop, what is a workstation ?
fronty
Member
Member
Posts: 188
Joined: Mon Jan 14, 2008 5:53 am
Location: Helsinki

Re: OS without MMU

Post by fronty »

Benk wrote:with C your still dealing with some seg fault , or looking up some threading.
If you don't know how to program in C and use some kind of threading with it, it doesn't mean no one else doesn't know.
Benk
Member
Member
Posts: 62
Joined: Thu Apr 30, 2009 6:08 am

Re: OS without MMU

Post by Benk »

Neolander wrote:I understand the time constraint argument, but what you're proposing implies dropping ALL native code (C, C++, Pascal, Pascal object, ObjectiveC, and so on...) and switch to interpreted code everywhere in user space. Because native compiled code does not include any notion of type anymore, as you probably know. For machine code, a pointer is just an unsigned integer. No more,no less.
Not interpreted ( or even JIT ) at all ,but AOT compiled , all that is required is that the compiler can check where all memory references are going so any GC based language is fine. Cs abbility to create any memory reference makes this difficult.

Note the OS uses a compiler IR for all files and compiles it specifically for the machine upon install time. You could use LVVM IR for these but a C verifier is very difficult.
And then about that "very little performance gain". I've heard about how small it is many times. And indeed it's true when you run complex library functions and have all libraries written in native code (again, you can't get around the need of such code :P), because the instruction decoding + real-time parameter checking + garbage collection + various sandboxing + call + <insert other bloat here> overhead is small compared with the execution time of the function. As an example, Pardus linux have their package manager written in python, and except through the memory footprint you just couldn't tell. But for something that requires executing a lot of simple instructions, like physics, that overhead is too high, unless you have some NASA computer. Believe me, I've tried.
Compared to assembler C is still bloat , you can argue the same thing ( eg L4) ..

re .." instruction decoding + real-time parameter checking + garbage collection + various sandboxing + call + <insert other bloat here> overhead is small compared with the execution time of the function"

None of this occurs , it will all be compiled even Python and java script , there is no param checking etc though there is additional memory checking at compile time. GC is the major issue and most of my work has been on avoiding GC pauses (esp for 3D) , concurrent GCs can do the full mark on other threads reducing the impact to about 4% ( which you get back 2-4 fold from not using kernel protection) .

In terms of memory i used to run C++ MFC and .NET well on a 200 Mhz Arm with 32 Meg of memory , the C# version of the app was more functional , about the same speed and smaller . Using a single run time will avoid most of the bloat you see at the moment with different runtimes and versions of runtimes.

Lastly I think the OO difference is the big one , OO is not suited where you need the highest performance but you can write static C like code in C# but few people have the skill, you cant use pointer arithmatic out side of trusted libs.

Im also working with allowing some trusted libs and runtimes to be native in such an environment especially for 3D.

Lastly on massive multicores , immutable data will rule , and Ocaml is a better fit. Though Ocaml is a difficult language to learn better suited to scientists.

In my opinion, the best way to do fast application development is to have a smart and rigorous compiler + some powerful code generation systems. That approach was used by Delphi for rapid GUI application development, and it worked damn well (though I may be biased since I learned how to program with delphi :mrgreen: ). But well, now developers require the computer to do more and more of their own homework at execution time. I'm fine with that as long as I can write efficient code in pascal or C(++) myself, I just hope that OS manufacturers won't *ever* make going through that bloat a requirement, as you've written above...

PS : And, by the way, C *is* type-safe, as long as you don't cast everything without a single thought... :roll: On the other hand, you mention OCaml, while some quick research tells me that in this language, you can put pretty much everything in a variable without declaring its type first... Maybe you should have a second look at what C really does *before* bashing it for the sake of bashing it...

It is compiled code... and such generators work fine.

I spent 1 years on asm , 10 years on C , 8 years on C# ,2 years embedded C++ , 6 months on Ocaml . I still use C for some Kernel components. Note both C# and Ocaml dont require you to declare the type as long as it can be automatically inferred ( C doesnt require this) . It is then compiled to IR ( intermediate Representive) with the type.

The problem with C is while the system can run C code ( and does for some trusted libs which are "trusted" to be not malicious are well tested , and low in bugs) it cannot verify at compile time that the code is safe
1. You can maliciously cast structs to the wrong type or create buffer overuns ( a lot of hacks are based on these) .
2. you can assign the value of a runtime determined function to a function pointer ( or data pointer) and then execute random code or trash data. Its possible to compile it to have runtime checks for pointers and to put malloc calls to use a GC for memory but then you basically have a bad C# ( which will run slower due to runtime checks which C# doesnt need)..

Its worth noting there are libs which use smart pointers and GC tyle allocators and it is likely that these more modern C programs would run. The OS iself is language agnostic it uses an IR ( which can be CIL or something like LVVM IR) of things that are safe to do , If it can be compiled to an IR which is safe it would work , this could include a C app with such a lib but not the typical C app.
Benk
Member
Member
Posts: 62
Joined: Thu Apr 30, 2009 6:08 am

Re: OS without MMU

Post by Benk »

fronty wrote:
Benk wrote:with C your still dealing with some seg fault , or looking up some threading.
If you don't know how to program in C and use some kind of threading with it, it doesn't mean no one else doesn't know.

If you think you can write bug free, good high thread count C code in 2 hours ( including testing ) your the best C programmer i have ever worked with and I have worked with a LOT in the last 20 years...
Benk
Member
Member
Posts: 62
Joined: Thu Apr 30, 2009 6:08 am

Re: OS without MMU

Post by Benk »

gerryg400 wrote:
99% code is written under time constraint , c code is buggy and takes a lot longer for very little performance gain.

Implement an algortihm in 2 hours i bet Ocml will be 10* faster on 10+ cores , c# will be faster and with C your still dealing with some seg fault , or looking up some threading.
What evidence do you have for this. Think about some of the projects you have been involved in. How, when the actual coding phase of a correctly engineered software project represents barely 20% of the project time, can you can blame the programming language for the bugs you have. Surely the insane scheduling, scrappy requirements gathering, non-existent system engineering, and poor testing methodology are the cause of the majority of bugs. C is not to blame. And a c program that seg-faults is no worse than a java program that gives the wrong answer.

- gerryg400
Intelligent response , the best way is to go to teams that just code and have the specs pre done.. There are typically 2 teams , the VB ( or Ruby or Perl or Python etc) style teams who code day in day out and the project teams who are far less productive but write far more critical code. I have always been on the OO big project teams but im amazed at what the VB and other high level language guys produced given the time.
Anyway in my experience there are less bugs and nasty issues with Java and .NET based languages especially phantom crash and weird behaviour type bugs which take a long time to track down. This results in insane scheduling, ever had a bug you spend months trying to find /reproduce I have in C never in C#. I remember one ( not mine ) that took 9 months to find what happened was under load and when using the floppy and HD the stack would corrupt and write the floppy FAT over the HD. A rare , very painfull and anoying bug. It was a C buffer overun in an interupt routine.

Its worth noting the best C teams end up using smart pointer libs and checked or GC type memory allocators so are almost using C# anyway.

re

"And a c program that seg-faults is no worse than a java program that gives the wrong answer."
How long do they take to debug or fix the issue ?

The number one issue with C is if you allow its bad behaviour (which good programers never produce :) ) you also allow malicious code that does exploit this. If you ban these things you eliminate whole classes of bugs and exploits . eg incorrect type , memory allocation , stray /null pointers , buffer over runs etc

There is nothing to say a language needs to be interpreted , get wrid of the above and you have a language like C# which can be full compiled Ahead of Time eg mono LVVM.

Lastly that does not mean i wouldnt use C or even asm for certain cases I have and i will esp for critical OS code like IPC or a runtime. But for a user app , it would need some very special requirements which couldnt be fixed by a cheaper hw upgrade.
Post Reply