Friday, February 23, 2007

Update - Interfaces

Hi, This has been a hard week... Last week I was able to get the display component to work but it did not use methods. In fact, this is the first time I am using the methods capability as an interface. I have done some re-designing and nearly finished implementing the changes. Untill now, each method was a seperate entity which linked into its module. Now it will work differently. The problem with this is that if a module was updated, it would have to search all objects for instances of the methods and update them each. An invalid function pointer means a crash or worse loss of information. The new implementation is that each module holds its interface of methods it supports with each entry holding the method name (i.e. UIShapeDraw) and its relative function address. The advantage is that there is central location for methods where interfaces can be updated easily by just replacing the lookup table. This will also make it easier to define an interface and all a method needs to do is hold the moduleId and the function name and index. The index is used for caching purposes (so we dont have to lookup the function each time by name). The kernel works mostly this way but did not have the function name lookup. The size of the function name is up to 32 bytes. Remember that the function name is the function name you would call in your code, so it should not be longer than 32 bytes anyway. This limit can be changed in future versions if needed. This design is easier to maintain and understand. I will also extend this to the kernel so that it will be very easy to look at the system and see all methods in the system. Because the interface entry index is passed in the message passing instead of the function address, it makes it more secure so that bad addresses cannot be passed without residing in an interface object. It also makes installations easier since a module can register itself through a method directly. This should avoid the problems of having to register every module in the system. I am very happy with the way things are turning out.

No comments: