Statistics
| Branch: | Revision:

iof-bird / bird-2.0.1 / lib / resource.sgml @ 6b3f1a54

History | View | Annotate | Download (1.53 KB)

1
<!--
2
	BIRD Programmer's Guide: Resources
3

    
4
	(c) 2000 Martin Mares <mj@ucw.cz>
5
-->
6

    
7
<chapt>Resources
8

    
9
<sect>Introduction
10

    
11
<p>Most large software projects implemented in classical procedural
12
programming languages usually end up with lots of code taking care
13
of resource allocation and deallocation. Bugs in such code are often
14
very difficult to find, because they cause only `resource leakage',
15
that is keeping a lot of memory and other resources which nobody
16
references to.
17

    
18
<p>We've tried to solve this problem by employing a resource tracking
19
system which keeps track of all the resources allocated by all the
20
modules of BIRD, deallocates everything automatically when a module
21
shuts down and it is able to print out the list of resources and
22
the corresponding modules they are allocated by.
23

    
24
<p>Each allocated resource (from now we'll speak about allocated
25
resources only) is represented by a structure starting with a standard
26
header (struct <struct/resource/) consisting of a list node (resources are
27
often linked to various lists) and a pointer to <struct/resclass/ -- a resource
28
class structure pointing to functions implementing generic resource
29
operations (such as freeing of the resource) for the particular resource
30
type.
31

    
32
<p>There exist the following types of resources:
33

    
34
<itemize>
35
<item><it/Resource pools/ (<struct/pool/)
36
<item><it/Memory blocks/
37
<item><it/Linear memory pools/ (<struct/linpool/)
38
<item><it/Slabs/ (<struct/slab/)
39
<item><it/Events/ (<struct/event/) 
40
<item><it/Timers/ (<struct/timer/) 
41
<item><it/Sockets/ (<struct/socket/) 
42
</itemize>