Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I execute any c made prog without any os platform?

I googled about it and somewhere I read ....

Yes, you can. That is happening in the case of embedded systems

I think NO, it's not possible. Any platform must have an operating system. Or else, your program must itself be an OS. Either soft or hard-wired. Without an operating system your component wouldn't work.

Am I right or can anybody explain me the answer? (I dont have any idea abt embedded systems...)

like image 796
Mohit Jain Avatar asked Nov 12 '09 14:11

Mohit Jain


2 Answers

Of course you can. All a (typical) CPU needs is power and access to a memory, then it will execute its hard-coded boot sequence.

Typically this will involve reading some pre-defined address, interpreting the contents there as instructions, and starting to run them.

These instructions could of course come from a C program, although at this level it's more common to write the very early stages (called bootstrapping) in assembly.

This of course doesn't mean, if I were to read your question title literally, that any C program be run this way. If the program assumes there is an OS, but there isn't, it won't work. This should be pretty obvious.

like image 132
unwind Avatar answered Sep 30 '22 03:09

unwind


You can run a program in a system without an Operating System ... and that program need not be an Operating System itself.

Think about all the computers (or processors if you prefer) inside a car: engine management, air conditioning, ABS, ..., ...
All of those system have a program (possibly written in C) running. None of the processors have an OS.

The Standard specifically differentiates between hosted implementations and freestanding implementations:

    5.1.2.1 Freestanding environment
1   In a freestanding environment (in which C program execution may take place
    without any benefit of an operating system), the name and type of the
    function called at program startup are implementation-defined. Any library
    facilities available to a freestanding program, other than the minimal set
    required by clause 4, are implementation-defined.
2   The effect of program termination in a freestanding environment is
    implementation-defined.

    5.1.2.2 Hosted environment
1   A hosted environment need not be provided, but shall conform to the
    following specifications if present.
    ...

like image 34
pmg Avatar answered Sep 30 '22 03:09

pmg