Hot answers tagged

263

There are plenty of websites that go through the boot process (such as How Computers Boot Up). In a nutshell, its a multi-stage process that keeps building up the system a little bit at a time until it can finally start the OS processes. It starts with the firmware on the motherboard which tries to get the CPU up and running. It then loads up the BIOS ...


175

A "bare metal" operating system doesn't run within anything. It runs the full instruction set on the physical machine, and has access to all of physical memory, all device registers and all privileged instructions, including those that control the virtual memory support hardware. (If the operating system is running on a virtual machine, it may think it is ...


86

Polling refers to repeatedly checking whether a resource (any kind of resource) is ready. A spinlock is when the resource you are polling is a lock. Note that polling is not bad. In particular, polling is efficient when there is usually data ready when you poll. Polling is only inefficient if you do it without then getting any data in return. On the other ...


62

In the beginning there was no power in the CPU. And the Man said "let there be power", and the CPU started to read from a given address in memory and execute the instruction that was present there. Then the next one and so on until the end of the power. This was the boot up. Its task was to load another piece of software to gain access to the environment, ...


31

It's mostly for historical reasons. Some parts of the windows kernel were originally written in C, because 1983, over three decades ago, when Windows 1.0 was unleashed, C++ was barely released. Now these C-libraries will stay there "forever", because Microsoft made backward-compatibility a selling point and rewriting a bug-compatible version of the C-parts ...


30

Sorry to be late, but I'll describe it as such: The motherboard gets power. Timing circuits start and stabilize if necessary, based solely on their electrical characteristics. Some newer devices may actually use a very limited microprocessor or sequencer. It should be noted, alot[sic] of the things like "timing circuits start and stabilize if necessary" ...


24

As most people have pointed out, reasons are by far historical, but there is something else no one is mentioning and I believe it is the reason people still write C code for low-level. C is a small language in the sense that the spec is (relatively) short. C++ is huge and that's an understatement. This may not matter that much to the programmer (although I ...


15

The C runtime is much smaller. The translation of C++ into lower-level constructs is less transparent than in C. (See references and vtables, for two quick examples) C usually has a stable ABI. C++ usually does not. This means that at the bare minimum, the system call interface should be C style. In addition, if you want any sort of dynamic modules, ...


15

There are many good answers but I wanted to add this: You mentioned you come from a Python background. Python is a ninterpreted (or "interpiled" or whatever, at least in typical CPython use cases) language. This means you have some other software (the Python interpreter) looking at the source and executing it in some way. This is a fine model and allows ...


12

You ask "How can an application run without being in an OS". The easy answer is "an OS is not an application". While an OS can be created with the same tools as an application, and made out of the same raw material, they are not the same thing. An OS doesn't have to play by the same rules as an application. OTOH, you can think of the actual hardware and ...


11

The reasons aren't technical. A little bit of assembly is unavoidable, but they aren't forced to use the occasional C, they want to. My company uses its own proprietary kernel, written almost entirely in C++, but we don't need to support a C interface to the kernel like most everyone else, because our embedded kernel is monolithically compiled with our C++ ...


10

Yes, he would need permission from every person who has contributed code to the project. This is because those people have only given permission to redistribute their code under the GPL. Some other projects circumvent this by requiring that contributors assign their rights to the project.


10

A spinlock is a type of lock, specifically, one achieved via polling. Polling is a method of checking the status of something (by asking for the status, as opposed to waiting to be told the status). Not all polling is a spinlock, for example, polling the status of keyboard keys. Also, polling isn't inherently bad. Very short periods of polling can avoid ...


9

These are annotations used by Sparse, the Static Analysis Tool for the Linux Kernel, originally written by Linus Torvalds. When compiled normally, without Sparse, they are simply #defined away to nothing. The definitions are in include/linux/compiler.h: # define __releases(x) __attribute__((context(x,1,0))) This one uses the __attribute__ non-standard ...


6

Answer to your question requires the knowledge of how the native (for CPU) code looks like and how is it interpreted by CPU. Usually whole compilation process is based of translating things you write in C, Pascal or even Python (using pypy) and C# into things CPU understands, i.e. simple instructions like "store something under [memory address]", "add ...


6

Kernel developers are often the kind of people, who feel happier, when it is immediately evident from the source, what the code actually does. C++ has many more features, which hide what the code does more than plain C code hides it: overloads, virtual methods, templates, references, throws... C++ also has vastly more syntax you have to master in order to ...


5

The idea of Tivoisation is relevant to this topic. In the case of TiVo, their box ran Linux and they did release the source to the changes they made. However, they didn't allow you to load modified versions onto the box. So technically they fulfilled their obligation. IANAL, but here's my non-legal understanding: The GPLv2 says they have to make any ...


5

Bjarne Stroustrup, in an interview in July 1999: None of these languages was radically different or dramatically better than other contemporary languages. They were, however, good enough and the beneficiaries of luck and social factors


5

Spinlock is different from polling because it only occurs for a very short period of time, on the order of a few milliseconds or less. Polling can go on indefinitely. In parallel programming, a brief episode of spinning is often preferable to blocking, as it avoids the cost of context switching and kernel transitions. Further Reading SpinLock and SpinWait ...


5

Different types of UNIX have different architectures. In Linux and traditional monolithic UNIX systems the kernel is not a process. It's a block of code and data that is mapped into the memory space of every process (usually at addresses with the high bit set), but with a different I/O Privilege Level. When a process makes a system call, that triggers an ...


5

Yes. The Windows NT kernel API (which is traditionally accessed by using the functions defined in ntdll.dll) can be accessed directly by use of the int 2e instruction. However this is not a supported way of using the system, and details of the implementation (including function codes) are likely to change between Windows versions. The basic approach is: ...


5

The kernel has a very defined API for file handling Right. And that API includes other more granular capabilities. There is an API to allow access to e.g. format a drive, get model and serial information, hard disk temperarure, and a variety of other things. Some of the functions you are interested in are only available to privelged users, like root or ...


4

Polysemy. These are two different meanings of the same word. But you are correct to observe that Smalltalk has a lot of an operating system. This is because early Smalltalk systems predate today's operating systems and thus Smalltalk offers many services that are typically offered by the operation system today.


4

The difference is that a spinlock is (hopefully) only used in situations where it is appropriate, and in these situations it is very efficient. You use a spinlock if you expect that a resource will only be locked for a very short time - for example if a lock is only used to update a variable. The spinlock polls the lock at maximum speed, but hopefully for ...


4

You don't strictly need a heap to run either C or C++ programs that are compiled for your platform, but if you want to use heap-allocated objects or memory blocks, then you will need a heap. C++ uses heaps more than C code (ie routinely under the covers in libraries). In particular most use of the STL will want a heap, and C++ code uses the STL a fair ...


4

A Unikernel is a special type of a Library OS. A library OS offer all of it's functionality as a libraries, typically linked into the application compile-time. The distinction is not really clear, but originally when Anil Madhavapeddy coined the term Unikernel he meant a single threaded application, with everything running in single address space, using a ...


3

C is a very low-level language, by its design. It's one step away from assembler; knowing the chipset you're targeting, you could, with a little knowledge, manually "compile" C into ASM. This kind of "close-to-the-metal" language is key for high levels of optimization (for performance, memory-efficiency, etc). However, because it's this close to the metal, ...


3

To understand how operating systems work, it may be helpful to split them into two categories: those which simply provide services to applications upon request, and those which use hardware features in the CPU to prevent applications from doing things they shouldn't. MS-DOS was of the former style; all versions of Windows since 3.0 have been the latter ...


3

You can read the license at https://www.gnu.org/licenses/gpl.html . The relevant information is in section 6 which says they may: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. ...


3

There are some differences for how an operating system operates that are extremely system dependent. To be useful a system needs to have some predictable behavior on start-up, such as "start executing at address X". For systems that have non-volatile storage (such as Flash memory) mapped into their program space this is fairly easy since you just make sure ...


Only top voted, non community-wiki answers of a minimum length are eligible