45 Lecture
CS304
Midterm & Final Term Short Notes
RESOURCE MANAGEMENT
Resource management refers to the efficient allocation, utilization, and deallocation of system resources such as memory, CPU cycles, network connections, and file handles. Effective resource management ensures that system resources are used opt
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
Which of the following is not a common system resource that requires efficient management? a. Memory b. CPU cycles c. Input devices d. Network connections Answer: c Which of the following is not a technique used for efficient resource management? a. Resource pooling b. Resource caching c. Resource sharing d. Resource wasting Answer: d What is resource pooling? a. The process of allocating resources to specific tasks b. The process of sharing resources among multiple tasks c. The process of caching resources for future use d. The process of deallocating unused resources Answer: b Which of the following is an example of a resource leak? a. Using a caching mechanism for database queries b. Releasing memory after it has been used c. Failing to close a database connection d. Allocating resources dynamically Answer: c What is garbage collection? a. The process of deallocating unused memory b. The process of deallocating unused network connections c. The process of deallocating unused file handles d. The process of deallocating unused CPU cycles Answer: a What is resource caching? a. The process of allocating resources to specific tasks b. The process of sharing resources among multiple tasks c. The process of caching resources for future use d. The process of deallocating unused resources Answer: c What is resource sharing? a. The process of allocating resources to specific tasks b. The process of sharing resources among multiple tasks c. The process of caching resources for future use d. The process of deallocating unused resources Answer: b Which of the following is not a benefit of efficient resource management? a. Improved performance b. Increased reliability c. Reduced resource usage d. Increased memory leaks Answer: d Which of the following is an example of resource pooling? a. Sharing a database connection among multiple threads b. Allocating a fixed amount of memory for a process c. Caching query results for future use d. Deallocating memory when it is no longer needed Answer: a What is resource caching used for? a. To allocate resources to specific tasks b. To share resources among multiple tasks c. To cache resources for future use d. To deallocate unused resources Answer: c
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is resource management in C++? Resource management in C++ refers to the techniques used to handle and manage system resources, such as memory, files, network connections, etc. What is dynamic memory allocation in C++? Dynamic memory allocation is a mechanism provided by the language to allocate memory at runtime. The memory is allocated using operators such as new and delete. What is a smart pointer? A smart pointer is a class that provides automatic memory management for dynamically allocated objects. It automatically deletes the object it points to when it is no longer needed. What is RAII? RAII (Resource Acquisition Is Initialization) is a technique in C++ used to manage resource acquisition and release in a scoped manner. It ensures that resources are acquired and released in a predictable and safe way. How can you handle exceptions in C++? Exceptions can be handled using try-catch blocks. The code that might throw an exception is placed in the try block, and the catch block catches the exception and handles it appropriately. What is the difference between throw and throw() in C++? throw is used to throw an exception, while throw() is used to specify that a function does not throw any exceptions. What are the benefits of using smart pointers in C++? Smart pointers help prevent memory leaks and improve code safety by automatically releasing resources when they are no longer needed. They also simplify code by eliminating the need for manual memory management. What is the role of destructors in C++? Destructors are used to release resources acquired by an object when it is no longer needed. They are called automatically when an object is destroyed. What is the use of the std::unique_ptr class in C++? std::unique_ptr is a smart pointer that provides exclusive ownership of the object it points to. It automatically deletes the object when it is no longer needed. How can you prevent resource leaks in C++? Resource leaks can be prevented by using RAII, smart pointers, and exception handling. These techniques ensure that resources are acquired and released in a predictable and safe way, even in the presence of exceptions.