Resource managementA resource handle is an identifier for a resource that is currently being accessed. Resource handles can be opaque, in which case they are often integer numbers, or they can be pointers that allow access to further information. Common resource handles are file descriptors and sockets.
A situation when a computer program allocates a resource and fails to deallocate it after use is called a resource leak. Resource tracking is the ability of an operating system, virtual machine or other program to terminate the access to a resource that has been allocated but not deallocated after use. When implemented by a virtual machine this is often done in the form of garbage collection. Without resource tracking programmers must take care of proper manual resource deallocation. They may also use the RAII technique to automate this task.
Access to memory areas is often controlled by semaphores, which allows a pathological situation called a deadlock, when different threads or processes try to allocate resources already allocated by each other. A deadlock usually leads to a program becoming partially or completely unresponsive.
Access to resources is also sometimes regulated by queuing; in the case of computing time on a CPU the controlling algorithm of the task queue is called a scheduler.