Basics of Operating Systems every programmer needs to know
What actually is an Operating System?
An Operating System or an OS can be understood as the lowest layer of control you can get on your device. An Operating System manages the memory, processes, software and hardware of you computer. It is the method through which you are able to interact with your device. Without it, your device is just a lot of microchips and casing.
Your OS actually orchestrates the software asking the access to different amount memory, CPU and storage. Most devices mainly have 3 types of Operating Systems: Windows, MacOS or Linux.
Windows
It’s the most common OS that comes loaded to almost all the computers. It was built by Microsoft. It provides a really easy interface for everyday tasks like writing, content consumption, etc.
MacOS
MacOS is the OS that comes preloaded on Macintosh(Apple) computers. The devices are relatively expensive and hence this makes a small portion of the total OS. Though, most people prefer the look and feel of MacOS over windows.
Linux
The word Linux basically just means “Like Unix”. Unix is a command line based OS, while Linux is a GUI (More on GUI later). Linux makes the smallest portion of total number of OS but most of the servers use Linux as it is highly customizable and very powerful. If you are in development field, Linux is the way to go. You can find a Linux distro for whatever use you want.
- GUI — GUI or Graphical User Interface helps you navigate and use your operating system through the use of graphics(icons) and text. This makes it really easy to use for everyone.
- CLI — CLI or Command Line Interface as the name suggests means you control your computer through the use of Commands. This was provides you with far more control but this can be intimidating at first.
Command Line 101
If you are in any technical field be it Software development, DevOps or anything, you must know the importance the Command Line tools. These tools provide you with far more control over your machine and you can accomplish an array of tasks in far less time such as navigation, environment setup, etc. Commands can be different for different OS but these are the basic commands that work everywhere and you need to know.
- mkdir — make a directory(folder)
- cd(change directory) — change the directory from here to the path described
- ls — to show all the files and directories present in the directory
- touch — create files(not directories)
- mv — move this file
- cp — copy this file
- rm — remove this file(delete)
- curl — download files found at the specific url
If you want a detailed explanation and commands you can go to https://rb.gy/lnce7a
Threads, Processes and Programs
You must have heard these terms somewhere or the other but never got quite what these meant. Let me simplify them for you:
Programs
This one is easy. A collection of code that can be used to accomplish some kind of task is called a program. What you make through coding is a program. They can be bundled along with the OS as core programs or may accomplish only a certain task, then they are called an “application”.
Processes
When a program is ran, be it compiled or interpreted, it is loaded into the computer’s memory in a binary form as the CPU only understand binary. A program that has been loaded into the memory along with all the resources it needs to run is called a “Process”. Your OS handles the task of allocating the resources to turn your program to a process.
Threads
Threads are basically units of executions within a process. A process can have a single or multiple threads. When a process happens the CPU allocates some resources to the process, these resources are then shared by the threads in order to accomplish multiple subtasks within the task to complete it at a faster pace.
Concurrency and Parallelism
Now you might ask if the CPU run the processes and threads one after another or all at once? It depends on the kind of processor we are working with.
When you have a multiple core processor(most modern ones), you can truly run the processes and threads in parallel and accomplish different tasks. This is “Parallelism”.
But if you have a single core processor, your processes need to share the CPU in order to do the work more effectively. Using a process scheduling algorithm there is time slicing for different processes to run, this gives an illusion of parallel processing but it is not truly parallel.
There were the basics of operating systems every programmer, everyone for that matter, needs to know.
Thanks for staying!