Is it complicated to program an operating system for PC?

The answer is YES, you can judge it by studying the kernels of operating systems such as Unix, Mach, Minix, Plan 9.

There are parts that are more difficult than others such as multi-tasking, memory management, processor, task context management, peripherals, file system management, real time, and I voluntarily pass by so much the subject is dense!

I voluntarily quote these five kernels which for me represent the state of the art and which have been studied in depth by many students:

  1. Unix version 6 – see the Lion’s book for the sources
  2. Mach (kernel) – the top of the memory management
  3. Minix – the state of the art of Unix-like
  4. Plan 9 from Bell Labs – a Unix distributed via the network
  5. ChorusOS – Real-time Unix from Inria

At one time, there were specific and great courses on kernels, Université Paris 8, Free University of Amsterdam Рprof. Andrew Tanenbaum. Andrew S. Tanenbaum РWikipedia

Minix is certainly the most widely distributed Unix-like kernel in the world and one of the most aesthetically pleasing (Intel ME – See the history of Minix 3 and Amoeba (operating system) – Wikipedia).

For Unix aficionados, I recommend “The Life of Unix” if it is still published.

Thanks to all these great names in computer science who were able to transmit their passion for beautiful code. A special mention to Ken Thompson from Bell labs who was the pioneer not only on Unix but also on the creation of the first chess endgame database; Endgame tablebases: A short history
for which he received a second award (Ken Thompson – Chessprogramming wiki)

Note: When you have studied these OS, you master a lot of things in the computer world and it is an understatement to say that the subject is so vast!

I rather disagree with the other answers.

Coding a kernel is not difficult. It’s actually a study project of many students of DEUG or licence d’info. I did one myself and I’m far from being a computer genius. Was it modern and optimized? Certainly not. But it was a kernel, my PC booted on it and it worked.

Then, you have to consider that a complete operating system includes much more than the kernel: device drivers, a command line, a graphical interface, software… If you have to reinvent all that, yes, it’s a huge job I admit, but in essence it’s not particularly “complicated”. It would take a lifetime (or even several) to redo everything from scratch but you also have the possibility to port applications created for other OS to speed up the task.

tl;dr it’s not that complicated, it’s mostly time consuming, and you don’t have to start from scratch for everything.