TL;DR: I would like to know how a programming language, the OS and drivers work together to perform a task.
I (and we all) have used various softwares/modules/packages on the top of our OS which provides us with a very simple API/GUI/CLI to perform tasks. But one question which keeps me disturbing is:
How does that software/module/package actually perform any specified action? I mean, it actually should be instructing OS to do that. So, OS should be providing procedure calls. But many functionalities aren't provided by the OS itself but the device driver provides it. So, how does the OS know what functions are supported by this particular device? And how can we instruct a particular device to perform a particular task?
Like suppose we are planning to change the IP address of a computer, we can do it through the OS's GUI or CLI. IP address is a logical thing and doesn't belong to a specific device (hardware), so we don't need any device driver for that. Keeping this simple, how can I write a module in python (without using already available API functionality) to change the IP address of a computer? Suppose the language itself i.e. python or a module/package written in python provides this functionality that calling a function such as change_ip() does the task. But how does it actually work in background? I know the background job is different for different OSes but I don't know how that module/package/language interacts with the OS. Or is it doesn't actually interact with the OS and performs the operations itself? (Maybe its possible in some cases)
Now, some other example. Suppose I would like to change the MAC address of the machine. Now, this operation is device dependent (the Network Card). Also, few NICs doesn't support this MAC changing functionality. This is actually dependent on the device driver and not the driver itself. So how can the OS know if the function is supported or not? Also, if the module/package/language is directly performing tasks without the help of OS, how can it know if the functionality is supported?
A very few might understand this question.. I don't know how to ask.. I am pursuing BE in Computer Engineering and I know several concepts and theories. But our education system makes us learn the things separately and not understand them in a combined manner. Like what would be the benefit if I know Operating System and Python but I don't know how they interact with each other and work in a combined manner. So, this is the base of my query.
I looked for an answer on Google but never found one.. Thank you..