Notes and Summary:: Application Programming Interface (API)
Notes and Summary:: Application Programming Interface (API)
Purpose: APIs provide a high-level interface for developers to interact with the operating
system without needing to deal with the complexities of direct system calls.
Benefits of Using APIs:
Portability: Applications written using APIs can be compiled and run on any system that
supports the same API.
Ease of Use: APIs are generally easier to work with than direct system calls, which can
be more detailed and complex.
Runtime Environment (RTE): The RTE includes compilers, interpreters, libraries, and
loaders, and provides a system-call interface that links API calls to the actual system
calls in the OS.
System Call Interface: Each system call is associated with a number, and the system-call
interface uses a table to map these numbers to the corresponding system calls in the OS
kernel.
Parameter Passing: Parameters can be passed to the OS via registers, memory blocks, or
stacks. The method depends on the OS and the number of parameters.
Registers: Simplest method, but limited by the number of registers.
Memory Blocks: Used when there are more parameters than registers (e.g., Linux uses
this method for more than five parameters).
Stack: Parameters are pushed onto the stack by the program and popped off by the OS.
Process Control: Create, terminate, load, and execute processes. Also includes
getting/setting process attributes and managing memory.
File Management: Create, delete, open, close, read, write, and manipulate files and
directories.
Device Management: Request, release, read, write, and manage devices.
Information Maintenance: Get/set time, date, system data, and process/file/device
attributes.
Communications: Create/delete communication connections, send/receive messages, and
manage shared memory.
Protection: Control access to resources, get/set permissions, and manage user access.
4. System Services:
Linker: Combines relocatable object files into a single executable file, including necessary
libraries.
Loader: Loads the executable file into memory and assigns final addresses to program
parts.
Dynamic Linking: Modern systems use dynamically linked libraries (DLLs) that are loaded
as needed, reducing memory usage.
System Call Differences: Each OS has its own unique system calls, making applications
compiled for one OS incompatible with another.
Executable File Formats: Each OS has a specific binary format for executable files, which
must be followed for the OS to load and run the application.
Cross-Platform Solutions:
Interpreted Languages: Applications written in languages like Python or Ruby can run
on multiple OSs if the interpreter is available.
Virtual Machines: Languages like Java use a VM to run applications on different OSs.
Recompilation: Applications written in standard languages like C can be recompiled for
each OS.
7. Examples:
Arduino: A single-tasking system with no OS. Programs (sketches) are loaded into flash
memory and run directly on the hardware.
FreeBSD: A multitasking system where multiple programs can run concurrently. The shell
creates new processes using fork() and loads programs using exec().
Key Concepts:
API vs. System Calls: APIs provide a high-level interface for developers, while system calls
are low-level functions that interact directly with the OS.
System Call Categories: Process control, file management, device management,
information maintenance, communications, and protection.
System Services: These include file manipulation, status information, programming
language support, program loading, communications, and background services.
Linkers and Loaders: Linkers combine object files into executables, while loaders load
executables into memory for execution.
OS-Specific Applications: Applications are often OS-specific due to differences in system
calls and executable file formats, but cross-platform solutions like interpreted languages
and virtual machines can mitigate this.
2. True/False Questions:
What are the benefits of using APIs over direct system calls?
Answer: APIs provide portability, ease of use, and abstraction from low-level system call
details. They allow applications to run on any system that supports the same API.
What is the difference between static and dynamic linking?
Answer: Static linking includes all necessary libraries in the executable file, while
dynamic linking loads libraries as needed at runtime, allowing multiple processes to
share the same library in memory.
Why are applications often OS-specific?
Answer: Applications are OS-specific due to differences in system calls and executable
file formats. Each OS has its own unique system calls and binary formats, making
applications compiled for one OS incompatible with another.
These notes and questions should help you prepare for any exam questions related to the
material covered in the document.
Certainly! Here are some Multiple Choice Questions (MCQs) based on the summary provided:
4. System Services:
7. Examples:
1. What is Arduino?
a) A multitasking operating system
b) A single-tasking system with no OS
c) A high-level programming language
d) A type of system call
Answer: b) A single-tasking system with no OS
2. How does FreeBSD handle multitasking?
a) By using a single-tasking system
b) By creating new processes using fork() and loading programs using exec()
c) By using dynamic linking
d) By using interpreted languages
Answer: b) By creating new processes using fork() and loading programs using
exec()
8. General Concepts:
These MCQs cover the key concepts and functions of operating systems as outlined in the
summary. They should help reinforce your understanding of the material.
Certainly! Here are some fill-in-the-blank questions based on the summary provided:
1. "The primary purpose of an API is to provide a ________ interface for developers to interact
with the OS."
Answer: high-level
2. "APIs allow applications to be ________, meaning they can run on any system that supports
the same API."
Answer: portable
1. "System calls can be grouped into six major categories: process control, file management,
device management, information maintenance, communications, and ________."
Answer: protection
2. "The ________ system call category includes creating, terminating, and managing
processes."
Answer: process control
4. System Services:
1. "System programs that run in the background and provide services like disk checking and
error logging are called ________."
Answer: daemons
2. "The ________ system service includes compilers, assemblers, and debuggers for
programming languages."
Answer: programming-language support
1. "Applications are often OS-specific due to differences in ________ and executable file
formats."
Answer: system calls
2. "One way to make applications run on multiple operating systems is to use ________
languages like Python."
Answer: interpreted
7. Examples:
1. "The ________ is a single-tasking system with no operating system, where programs are
loaded into flash memory."
Answer: Arduino
2. "In FreeBSD, new processes are created using the ________ system call."
Answer: fork
8. General Concepts:
1. "The ________ provides a system-call interface that links API calls to system calls in the OS."
Answer: runtime environment (RTE)
2. "Dynamic linking allows multiple processes to share the same ________ in memory."
Answer: library
These fill-in-the-blank questions should help reinforce your understanding of the key concepts
and functions of operating systems as outlined in the summary.
Certainly! Here are some True/False questions based on the summary provided:
1. Application Programming Interface (API):
1. "System calls can be grouped into six major categories: process control, file
management, device management, information maintenance, communications, and
protection."
Answer: True
2. "The 'process control' system call category includes creating and terminating
processes."
Answer: True
3. "The 'file management' system call category includes managing hardware devices."
Answer: False (The 'file management' category includes managing files and directories,
not hardware devices.)
4. System Services:
1. "System programs that run in the background and provide services like disk checking
and error logging are called daemons."
Answer: True
2. "The 'programming-language support' system service includes compilers, assemblers,
and debuggers for programming languages."
Answer: True
3. "Background services (daemons) are responsible for managing memory allocation."
Answer: False (Background services handle tasks like disk checking and error logging,
not memory allocation.)
1. "Applications are often OS-specific due to differences in system calls and executable
file formats."
Answer: True
2. "Applications written in C can run on any operating system without modification."
Answer: False (Applications written in C need to be recompiled for each OS.)
3. "Interpreted languages like Python allow applications to run on multiple operating
systems without modification."
Answer: True
7. Examples:
8. General Concepts:
1. "The runtime environment (RTE) provides a system-call interface that links API calls
to system calls in the OS."
Answer: True
2. "Dynamic linking includes all necessary libraries in the executable file."
Answer: False (Dynamic linking loads libraries as needed at runtime, while static linking
includes all libraries in the executable file.)
3. "The system-call interface is responsible for managing memory allocation."
Answer: False (The system-call interface maps system call numbers to actual system
calls, but it does not manage memory allocation.)
These True/False questions should help reinforce your understanding of the key concepts and
functions of operating systems as outlined in the summary.