Computer Science – 16.1 Purposes of an Operating System (OS) | e-Consult
16.1 Purposes of an Operating System (OS) (1 questions)
Operating systems can significantly improve resource utilisation through techniques like memory pooling and shared libraries. These techniques reduce memory fragmentation and improve code reuse, leading to more efficient use of system resources.
Memory Pooling
Memory pooling is a memory allocation technique where a pre-allocated block of memory is divided into smaller, fixed-size blocks. Instead of allocating and deallocating memory for each request, the OS allocates blocks from the pool. This reduces the overhead associated with dynamic memory allocation (e.g., malloc and free in C/C++), which can lead to memory fragmentation.
Example: A web server might use a memory pool to store frequently accessed data structures, such as connection buffers. This avoids the overhead of repeatedly allocating and freeing memory for each incoming connection.
Benefits: Reduced memory fragmentation, faster allocation and deallocation, improved performance, and better predictability of memory usage.
Shared Libraries
Shared libraries (also known as dynamic libraries) are libraries that can be used by multiple processes simultaneously. Instead of each process having its own copy of the library code in memory, they all share a single copy. This reduces the overall memory footprint of the system and saves disk space.
Example: Many applications on a Linux system use the same shared libraries, such as libc (the C standard library). This means that only one copy of libc needs to be loaded into memory, regardless of how many applications are running.
Benefits: Reduced memory usage, reduced disk space usage, easier software updates (only the library needs to be updated), and improved system stability.
Trade-offs: Shared libraries can introduce potential security vulnerabilities if a compromised library is used by multiple processes. Versioning issues can also arise if different applications require different versions of the same library.