D
D
denisramus2015-11-04 18:02:44
C++ / C#
denisramus, 2015-11-04 18:02:44

Is it possible to write OS in pure C (without assembler inserts)?

Is it possible to write OS in pure C (without assembler inserts)?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
I
Immortal_pony, 2015-11-04
@Immortal_pony

Can.

J
jcmvbkbc, 2015-11-04
@jcmvbkbc

Here people write "it is possible", but none of them specifies at the same time what "pure C" is.
If "pure C" is only what the language itself provides, say the C99 or C11 standard, then you will have problems in the following areas:
- Interrupt control: usually done through special registers or special assembler instructions.
- interrupt handlers: depending on the architecture, you will need functions with special prologues and epilogues that save and restore all registers and possibly return in a special way.
- MMU control: usually performed through special registers or special assembler instructions.
- cache management:
- process spawning and context switching: could theoretically be done with setjmp/longjmp, but you'll have to figure out the jmpbuf structure for your architecture, as it will need to be filled in manually for new processes.

O
Oleg Tsilyurik, 2015-11-04
@Olej

It is forbidden.
But the main thing is not what is impossible, but what is not necessary .
P.S. "possible" is written by people who have never seen the code of any operating system.

M
mamkaololosha, 2015-11-04
@mamkaololosha

Yes, you can. Most likely you will have some kind of under-reader-writer on the disk and that's it. Read Tanenbaum. Or how Torvalds wrote Linux. OS is not a project for 1 person for an evening. Usually ideas like "now, right now, here's how I'll write everything! The world will shudder!" ends as quickly as they begin.

T
Tsiren Naimanov, 2015-11-04
@ImmortalCAT

You can shoot yourself without a bullet ...

E
Eddy_Em, 2015-11-04
@Eddy_Em

Impossible. Because it will be necessary to write at least gcc for this architecture → use assembler inserts (take, at least, handling interrupts, exceptions and all sorts of low-level shnyag).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question