When it comes to operating systems, Unix is the mother of operating systems. Members of rich Unix family are:
- SVR4 (by AT&T)
- BSD 4.4 (by University of California)
- HP-UX (Hewlett-Packard)
- Solaris (Sun Microsystems)
Mostly, Linux is considered to be a copy of UNIX. Lets hear the actual story now. Linux was actually a late addition to the family. It was written by Linus Torvalds back in 1991 and it was meant for IBM computers. As a matter of fact, in the world of operating systems, Linux has come up as a great operating system and it is welcomed with huge popularity. Commercial enterprise servers are running on Linux. Another cherry on the cake, Laptop and PC companies are also providing GNU Linux as a pre-installed OS on their systems so that individual users can also get a bite of it.
An extensive brain storming confusion is if Linux a kernel or Operating System. After some time, people just start ignoring this doubt as it never gets answered, well keep reading for the solution. What Linus Torvalds wrote was Linux kernel and it had a lot of features similar to UNIX one. Why it is confused with OS, actually commercially available distributions that provide graphical interface, compilers and other utilities along with Linux kernel are referred to as Linux Operating System.
Linux is, as they say, a UNIX-like kernel, because it has ‘some’ common features but still there are areas where they are not same. Difference between Unix and Linux can be understood by going through following points.
1. The difference in approach: There is a class of kernels that fall in Monolithic category, Monolithic ones are those which operate in one and only one process, they don’t have any other process for any kind of task. Another category is called Micro-kernel where core of the kernel is assigned one process while other processes are there for its side tasks like drivers, etc. Linux lies within Monolithic category with few exceptions in Micro-kernel.
2. Loadable kernel Modules: Unix systems are bound to have static links of new modules to be added or recently added. Linux differs here too, it supports new additions on the fly. For example, drivers can be loaded dynamically whenever they are needed. This feature is recognized as Loadable kernel Modules (LKM). This feature enables us to add any component dynamically without arising the need of compiling the whole kernel again. Unloading can also be performed in similar fashion. This adds to the flexibility of Linux.
3. Kernel threads: Kernel thread is an independent execution flow. It can be used to execute some user process or any kernel code. Most of the UNIX-like systems constitute kernel thread sets. Threads always operate in same address space, so it is not expensive to perform context switching on kernel threads in comparison to processes- this explains why Unix-like systems have kernel threads. Kernel threads are used, on linux, to execute kernel code.
4. Multi-threading: Multi-threaded applications are those which create multiple execution flows. These flows are also known as threads and are light weight processes. Nowadays all operating systems have support for multi-threading. Most of the UNIX-like operating systems LWP (read light weight process) are kernel thread based, while on the other hand Linux handles them a bit differently. In linux, LWP are created by calling the clone() function which leads to creation of separate processes. Same task can also be carried out with fork() function but clone() lets recently created processes share their memory, address space etc. Their working in shared environment gave them a name “threads”. Hence, multi-threading is supported by both of them but they differ in internal handling of it.
5. Preemption and non-preemption: We have a category of kernels which are able to pre-empt currently executing process and hence we call the preemptive kernels. Processes are run on a priority basis. If currently executing process is a low-priority one and a high-priority one process comes up, it can interrupt the current process and start executing itself. Non-preemptive kernels are those which don’t forcibly interrupt the current process even if a high-priority process has to wait. Linux based operating systems are non-preemptive while UNIX systems are fully preemptive. Linux based Realtime operating systems are found to be fully-preemptive.
Bottom line, despite taking the basic idea from UNIX it still differs in some aspects because it has inherited a lot from it and will always be considered a part of Unix family.