Information Technology Reference
In-Depth Information
Kernel Code
Dynamic Aspect
Woven dynamic aspect code
Replaced instruction in original
code
branch
Jump back to instruction after
join point
Figure 3.5.
TOSKANA Code Splicing.
3.7.1
The TOSKANA Toolkit
Engel and Freisleben [33] have developed the TOSKANA toolkit to dynamically
apply aspects to the NetBSD operating system. This toolkit provides a set of
tools, macros and libraries for developing and deploying dynamic aspects in the
kernel space of NetBSD.
Aspects are developed using standard C macros and are inserted into the
kernel as loadable kernel modules. A runtime library, called aspectlib.ko ,dynam-
ically applies join points using a technique known as code splicing . Code splicing
replaces the bit patterns of instructions in native code with a branch to a loca-
tion outside the predefined code flow, where additional instructions followed by
the originally replaced instruction and a jump back to the instruction after the
splicing location are inserted. As the execution of kernel functions may usually be
interrupted at any time, the splicing operation is performed atomically [33]. This
process is illustrated in Figure 3.5 5 .
TOSKANA supports before , after and around advice variants and these are
implemented using the BEFORE, AFTER and AROUND macros in standard C
code as illustrated below:
#include <sys/aspects.h>
...
void aspect_init(void){ /∗ deploy three aspects ∗/
BEFORE(sys_open, open_aspect);
AFTER(sys_open, close_aspect);
AROUND(func, some_aspect);
}
ASPECT open_aspect(void){
...
}
5 This diagram is reproduced from Engel and Freisleben [33].
 
Search WWH ::




Custom Search