Saturday, December 14, 2013

T-Kernel based Questions and answers

How to check Stack overflow/underflow in eT-Kernel?
 
In T-kernel/extended, the stack overflow or underflow can be automatically detected, since the OS allocates 4 KB memory page just before and after the stack allocated. When the program access outside the stack, it will raise the exception without causing any damage to the data.
 
In T-kernel/compact, there is no such functionality to automatically detect the stack overflow/underflow. However, the maximum stack usage can be found using eBinder partscope. Also, in program also, it can be accessed through enabling extended debug support. It can be enabled through configuration as follows:
 
----
Configuration Root/
  Product Configuration
    Parts/
      eT-Kernel/
        T-Kernel/
          enable to reference maximum size of the stack
----
Then use the system call tdx_ref_tsk() and refer the rtsk->user_stack_peak_size and rtsk->system_stack_peak_size  fields. To use this system call, the following header file needs to be included.
 
#include
 
How to set the stack size in eT-kernel?
 
There are basic difference in the arguments and calling conventions between uT-kernel and T-kernel. For example, in uT-Kernel user space memory can be assigned as stack by enabling TA_USERBUF option. But, in copmact T-Kernel, the option has been changed as TA_USERSTACK.
 
When enabling the TA_USERSTACK, the stack can be assigned from user space memory. But, this cannot be performed if the task is running (created) at TA_RNG0 (highest) protection level.
 
Size of the stack can be assinged using stksz and sstksz. The system will allocate (stksz + sstksz) size memory for stack. In that stksz needs to be assigned by user. sstksz can be specified or can be left. If not specified, the default value from system configuration (TSysStkSz) will be used.
 
So, to control the total stack size, enable TA_SSTKSZ flag in attribute and specify the total stack size in either sstksz or in stksz or in dividing in both.

No comments: