Monday, 7 August 2017

Role of APIs, System calls & Device Drivers explained with example

Here, we are going to talk about API, System calls and device drivers. Lets start with API first.

API (Application Programming Interface): API are the functions or entry points provided by any application or system to use its features. Application developer need not to reinvent the wheel, he just uses the API available and manage to use the feature of different applications in his own application.ex. using Google map API in your application to identify location for given latitude and longitude.
From system perspective, application developer uses the system API to access certain features or resources provided by system in simplified manner. Application developer need not to develop the process or method to access the system so his job is simplified and fast. ex. accessing ram space by any application

System calls: System calls are the entry point to kernel space so that any application can talk to kernel and make it understand what is needed by them.ex. we can use google apis to access location in any application but sohow this intend is to told to kernel so that it can further talk to processor about same and make hardware work for application requirements. Actual work have to done by hardware anyhow, so it must be requested from it to activate GPS and find the exact latitude and longitude. Another example could be copying set of contents into file. Actual work of copying dat have to carried out by processor and system calls help to inform kernel that 'now' copy action need to be performed from where to where....

Device Driver: This piece of code would help processor talk to specific hardware in 'right' manner so that exactly what is intended is what is done by hardware. Take the same example of google apis. Here, processor need to talk to GPS and ask it to fetch the exact latitude and longitude rather than fetching area name. So Device Driver helps to establish talk between processor and hardware and let it perform the right task.

Now, linking all three in same example.....Google apis (API) would be used by application named 'GPS tracker' to fetch and latitude and longitude, which would inform kernel about this activity via system calls. Further kernel would inform processor about same and then processor uses correct device driver in right manner to get the location with help of GPS hardware. Now this latitude and longitude given by GPS hardware would be passed from processor to kernel, from kernel to API via system call and finally displayed on the 'Google Tracker' application.

Hope I have made myself clear :-)

Lets keep learning! Please post your comments below :-)

No comments:

Post a Comment