SlideShare a Scribd company logo
Microkernel development: from project to implementation Rodrigo Maximiano Antunes de Almeida E-mail: rmaalmeida@gmail.com Twitter: @rmaalmeida Universidade Federal de Itajubá
Creative Commons License The work ” Microkernel development: from project to implementation ” of Rodrigo Maximiano Antunes de Almeida was licensed with  Creative Commons 3.0 – Attribution – Non Commercial – Share Alike license . Additional permission can be given by the author through direct contact using the e-mail: rmaalmeida@gmail.com
“ I reinvented the wheel last week. I sat down and deliberately coded something that I knew already existed, and had probably also been done by many many other people. In conventional programming terms, I wasted my time. But it was worthwhile, and what's more I would recommend almost any serious programmer do precisely the same thing.” James Hart
//today topics void  main  (void){ //variable declaration kernel_project ( 1 ); //initialization concepts ( 2 ); //hard-work microkernel ( 3 ); }
void  kernel_project   (float  i ){ what_is_a_kernel ( 1.1 ); alternatives ( 1.2 ); kernel_design_decisions ( 1.3 ); }
kernel_project ( 1 );
kernel_project ( 1 ); Kernel tasks: Manage and coordinate the processes execution using “some criteria” Manage the free memory and coordinate the processes access to it Intermediate the communication between the hardware drivers and the processes
kernel_project ( 1 ); Alternatives Windows Embedded Compact® VxWorks® X RTOS® uClinux FreeRTOS BRTOS
kernel_project ( 1 ); Monolithic kernel versus microkernel Linus Torvalds and Andrew Tanenbaum
kernel_project ( 1 ); Kernel design decisions I/O devices management Process management System safety
kernel_project ( 1 ); Our decisions: Microkernel Non-preemptive Cooperative No memory management Process scheduled based on timer Isolate drivers using a controller
void  concepts  (float  i ){ function_pointers ( 2.1 ); temporal_conditions ( 2.2 ); void_pointers ( 2.3 ); }
concepts ( 2 ); function_pointers ( 2.1 );
concepts ( 2 ); Function pointers Work almost as a normal pointer Hold the address of a function start point instead the address of a variable The compiler need no known the function signature to pass the correct parameters and the return value. Awkard declaration (it is best to use a typedef)
concepts ( 2 ); //defining the type pointerTest //it is a pointer to function that: //  receives no parameter //  returns no parameter typedef   void   (* pointerTest )(void); //Function to be called void  nop  (void){  __asm NOP __endasm  } //creating an pointerTest variable; pointerTest   foo ; foo   =   nop ; (* foo )();  //calling the function via pointer
concepts ( 2 ); temporal_conditions ( 2.2 );
concepts ( 2 ); In the majority part of embedded systems, we need to guarantee that a function will be executed in a certain frequency. Some systems may even fail if these deadlines are not met.
concepts ( 2 ); To implement temporal conditions: There must be a tick event that occurs with a precise frequency The kernel must be informed of the execution frequency needed for each process. The sum of process duration must “fit” within the processor available time.
concepts ( 2 ); 1 st  condition: Needs an internal timer that can generate an interrupt. 2 nd  condition: Add the information for each process when creating it 3 rd  condition: Test, test and test. If fail, change chip first, optimize only on last case
concepts ( 2 ); Scheduling processes: Using a finite timer to schedule will result in overflow Example: scheduling 2 processes for 10 and 50 seconds ahead.
concepts ( 2 ); And if two process are to be called in the same time?
concepts ( 2 ); Question: From the timeline above (only the timeline) is P2 late or it was scheduled to happen 55(s) from now?
concepts ( 2 ); Solution: Use a downtime counter for each process instead of setting a trigger time. Problem: Each counter must be decremented in the interrupt subroutine. Is it a problem for your system?
concepts ( 2 ); void_pointers ( 2.3 );
concepts ( 2 ); Void pointers Abstraction that permits to the programmer to pass parameters with different types to the same function. The function which is receiving the parameter must know how to deal with it It can not be used without proper casting!
concepts ( 2 ); char   * name   =   "Paulo" ; double   weight   =   87.5 ; unsigned   int   children   =   3 ; void   main   (void){ //its not printf, yet. print ( 0 ,   & name ); print ( 1 ,   & weight ); print ( 2 ,   & children ); }
concepts ( 2 ); void  print (int  option ; void * parameter ){ switch( option ){ case  0 : printf ( "%s" ,(char*) parameter ); break; case  1 : printf ( "%f" ,*((double*) parameter )); break; case  2 : printf ( "%d" ,*((unsigned int*) parameter )); break; } }
void  microkernel  (float  i ){ init_kernel ( 3.0 ); for(int   i = 1 ;  i < 4 ;  i ++;) { kernel_example ( 3 + i / 10 ); } }
microkernel ( 3 ); init_kernel ( 3.0 );
microkernel ( 3 ); We will present the examples using a minimum of hardware or platform specific commands. Unfortunately some actions (specifically the timer) needs to access the hardware. We'll present a brief resume about our platform and some custom headers.
microkernel ( 3 ); //CONFIG.H code char at   0x300000   CONFIG1L   =   0x01 ;   // No prescaler used code char at   0x300001   CONFIG1H   =   0x0C ;   // HS: High Speed Cristal code char at   0x300003   CONFIG2H   =   0x00 ;   // Disabled-Controlled by SWDTEN bit  code char at   0x300006   CONFIG4L   =   0x00 ;   // Disabled low voltage programming //INT.H void   InicializaInterrupt (void); //TIMER.H char   FimTimer (void); void   AguardaTimer (void); void   ResetaTimer (unsigned   int   tempo ); void   InicializaTimer (void); //BASICO.H (only part of it) #define   SUCCESS   0 #define   FAIL   1 #define   REPEAT   2 //bit functions #define   BitFlp ( arg , bit )   (( arg )   ^=   ( 1 << bit ))   //special register information #define   PORTD   (*(volatile __near   unsigned   char*) 0xF83 ) #define   TRISC   (*(volatile   __near   unsigned   char*) 0xF94 )
microkernel ( 3 ); //first implementation kernel_example ( 3 + 1 / 10 );
microkernel ( 3 ); In this first example we will build the main part of our kernel. It should have a way to store which functions are needed to be executed and in which order. This will be done by a static vector of pointers to function //pointer function declaration typedef   void(* ptrFunc )(void); //process pool static   ptrFunc   pool [ 4 ];
microkernel ( 3 ); Each process is a function with the same signature of ptrFunc void   tst1 (void){ printf ( &quot;Process 1\n&quot; ); } void   tst2 (void){ printf ( &quot;Process 2\n&quot; ); } void   tst3 (void){ printf ( &quot;Process 3\n&quot; ); }
microkernel ( 3 ); The kernel itself consists of three functions: One to initialize all the internal variables One to add a new process One to execute the main kernel loop //kernel internal variables ptrFunc   pool [ 4 ]; int   end ; //kernel function's prototypes void   kernelInit (void); void   kernelAddProc (ptrFunc   newFunc ); void   kernelLoop (void);
microkernel ( 3 ); //kernel function's implementation void  kernelInit (void){ end  =  0 ; } void  kernelAddProc (ptrFunc  newFunc ){ if ( end  < 4 ){ pool [ end ] =  newFunc ; end ++; } }
microkernel ( 3 ); //kernel function's implementatio n void  kernelLoop (void){ int  i ; for(;;){ //cycle through the processes for( i = 0 ;  i < end ;  i ++){ (* pool [ i ])(); } } }
microkernel ( 3 ); //main loop void  main (void){ kernelInit (); kernelAddProc ( tst1 ); kernelAddProc ( tst2 ); kernelAddProc ( tst3 ); kernelLoop (); }
microkernel ( 3 ); Simple?
microkernel ( 3 ); //second implementation //circular buffer and struct added kernel_example ( 3 + 2 / 10 );
microkernel ( 3 ); The only struct field is the function pointer. Other fields will be added latter. The circular buffer open a new possibility: A process now can state if it wants to be rescheduled or if it is a one-time run process In order to implement this every process must return a code. This code also says if there was any error in the process execution
microkernel ( 3 ); //return code #define   SUCCESS   0 #define   FAIL   1 #define   REPEAT   2 //function pointer declaration typedef   char(* ptrFunc )(void); //process struct typedef   struct   { ptrFunc   function ; }   process ; process  pool [ POOL_SIZE ];
microkernel ( 3 ); char  kernelInit (void){ start  =  0 ; end  =  0 ; return  SUCCESS ; } char   kernelAddProc (process   newProc ){ //checking for free space if   (   (( end + 1 )% POOL_SIZE )   !=   start ){ pool [ end ]   =   newProc ; end   =   ( end + 1 )% POOL_SIZE ; return   SUCCESS ; } return   FAIL ; }
microkernel ( 3 ); void   kernelLoop (void){ int   i = 0 ; for(;;){ //Do we have any process to execute? if   ( start   !=   end ){ printf ( &quot;Ite. %d, Slot. %d: &quot; ,   i ,   start ); //check if there is need to reschedule if   ((*( pool [ start ]. Func ))()   ==   REPEAT ){ kernelAddProc ( pool [ start ]); } //prepare to get the next process;   start   =   ( start + 1 )% POOL_SIZE ; i ++;   // only for debug; } } }
microkernel ( 3 ); //vector of structs process  pool [ POOL_SIZE ]; //  pool[i] //  pool[i].func //  *(pool[i].func) // (*(pool[i].func))() //vetor of pointers for struct process*  pool [ POOL_SIZE ]; //  pool[i] //  pool[i].func //  pool[i]->func //  pool[i]->func()
microkernel ( 3 ); void   kernelLoop (void){ int   i = 0 ; for(;;){ //Do we have any process to execute? if   ( start   !=   end ){ printf ( &quot;Ite. %d, Slot. %d: &quot; ,   i ,   start ); //check if there is need to reschedule if   ( pool [ start ]-> Func ()   ==   REPEAT ){ kernelAddProc ( pool [ start ]); } //prepare to get the next process;   start   =   ( start + 1 )% POOL_SIZE ; i ++;   // only for debug; } } }
microkernel ( 3 ); Presenting the new processes void   tst1 (void){ printf ( &quot;Process 1\n&quot; ); return   REPEAT ; } void   tst2 (void){ printf ( &quot;Process 2\n&quot; ); return   SUCCESS ; } void   tst3 (void){ printf ( &quot;Process 3\n&quot; ); return   REPEAT ; }
microkernel ( 3 ); void   main (void){ //declaring the processes process   p1   =   { tst1 }; process   p2   =   { tst2 }; process   p3   =   { tst3 }; kernelInit (); //Test if the process was added successfully if   ( kernelAddProc ( p1 )   ==   SUCCESS ){ printf ( &quot;1st process added\n&quot; );} if   ( kernelAddProc ( p2 )   ==   SUCCESS ){ printf ( &quot;2nd process added\n&quot; );} if   ( kernelAddProc ( p3 )   ==   SUCCESS ){ printf ( &quot;3rd process added\n&quot; );} kernelLoop (); }
microkernel ( 3 ); Notes: Only process 1 and 3 are repeating The user don't notice that the pool is finite* Console Output: --------------------------- 1st process added 2nd process added 3rd process added Ite. 0, Slot. 0: Process 1 Ite. 1, Slot. 1: Process 2 Ite. 2, Slot. 2: Process 3 Ite. 3, Slot. 3: Process 1 Ite. 4, Slot. 0: Process 3 Ite. 5, Slot. 1: Process 1 Ite. 6, Slot. 2: Process 3 Ite. 7, Slot. 3: Process 1 Ite. 8, Slot. 0: Process 3 ... ---------------------------
microkernel ( 3 ); //third implementation //time conditions added kernel_example ( 3 + 3 / 10 );
microkernel ( 3 ); The first modification is to add one counter to each process //process struct typedef   struct   { ptrFunc   function ; int   period ; int   start ; }   process ;
microkernel ( 3 ); We must create an function that will run on each timer interrupt updating the counters void   isr (void)  interrupt   1 { unsigned   char   i ; i   =   ini ; while( i != fim ){ if(( pool [ i ]. start )>( MIN_INT )){ pool [ i ]. start --; } i   =   ( i + 1 )% SLOT_SIZE ; } }
microkernel ( 3 ); The add process function will be the responsible to initialize correctly the fields char   AddProc (process   newProc ){ //checking for free space if   (   (( end + 1 )% SLOT_SIZE )   !=   start ){ pool [ end ]   =   newProc ; //increment start timer with period pool [ end ]. start   +=   newProc . period ; end   =   ( end + 1 )% SLOT_SIZE ; return   SUCCESS ; } return   FAIL ; }
microkernel ( 3 ); if   ( start   !=   end ){ //Finding the process with the smallest start j   =   ( start + 1 )% SLOT _ SIZE ; next   =   start ; while ( j != end ){ if   ( pool [ j ]. start   <   pool [ next ]. start ){ next   =   j ; } j   =   ( j + 1 )% SLOT_SIZE ; } //exchanging positions in the pool tempProc   =   pool [ next ]; pool [ next ]   =   pool [ start ]; pool [ start ]   =   tempProc ; while( pool [ start ]. start > 0 ){ } //great place to use low power mode if   (   (*( pool [ ini ]. function ))()   ==   REPEAT   ){ AddProc (&( vetProc [ ini ])); } ini   =   ( ini + 1 )% SLOT_SIZE ; }
//today topics void  main  (void){ //variable declaration kernel_project ( 1 ); //initialization concepts ( 2 ); //hard-work microkernel ( 3 ); }
“ Don't Reinvent The Wheel, Unless You Plan on Learning More About Wheels” Jeff Atwood Microkernel development: from project to implementation Rodrigo Maximiano Antunes de Almeida E-mail: rmaalmeida@gmail.com Twitter: @rmaalmeida Universidade Federal de Itajubá
Ad

More Related Content

What's hot (20)

LLVM Register Allocation
LLVM Register AllocationLLVM Register Allocation
LLVM Register Allocation
Wang Hsiangkai
 
OSCh7
OSCh7OSCh7
OSCh7
Joe Christensen
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in Gecko
Chih-Hsuan Kuo
 
Machine Trace Metrics
Machine Trace MetricsMachine Trace Metrics
Machine Trace Metrics
Wang Hsiangkai
 
6 Synchronisation
6 Synchronisation6 Synchronisation
6 Synchronisation
Dr. Loganathan R
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
Mukesh Chinta
 
Ownership System in Rust
Ownership System in RustOwnership System in Rust
Ownership System in Rust
Chih-Hsuan Kuo
 
grsecurity and PaX
grsecurity and PaXgrsecurity and PaX
grsecurity and PaX
Kernel TLV
 
CSharp for Unity Day2
CSharp for Unity Day2CSharp for Unity Day2
CSharp for Unity Day2
Duong Thanh
 
Contiki introduction I.
Contiki introduction I.Contiki introduction I.
Contiki introduction I.
Dingxin Xu
 
Global Interpreter Lock: Episode I - Break the Seal
Global Interpreter Lock: Episode I - Break the SealGlobal Interpreter Lock: Episode I - Break the Seal
Global Interpreter Lock: Episode I - Break the Seal
Tzung-Bi Shih
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
Roger Xia
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
Chih-Hsuan Kuo
 
Monitors
MonitorsMonitors
Monitors
Mohd Arif
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
Instruction Combine in LLVM
Instruction Combine in LLVMInstruction Combine in LLVM
Instruction Combine in LLVM
Wang Hsiangkai
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
Shijin Raj P
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
Mahmoud Samir Fayed
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
Doug Hawkins
 
Exploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET ImplementationExploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET Implementation
nkslides
 
LLVM Register Allocation
LLVM Register AllocationLLVM Register Allocation
LLVM Register Allocation
Wang Hsiangkai
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in Gecko
Chih-Hsuan Kuo
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
Mukesh Chinta
 
Ownership System in Rust
Ownership System in RustOwnership System in Rust
Ownership System in Rust
Chih-Hsuan Kuo
 
grsecurity and PaX
grsecurity and PaXgrsecurity and PaX
grsecurity and PaX
Kernel TLV
 
CSharp for Unity Day2
CSharp for Unity Day2CSharp for Unity Day2
CSharp for Unity Day2
Duong Thanh
 
Contiki introduction I.
Contiki introduction I.Contiki introduction I.
Contiki introduction I.
Dingxin Xu
 
Global Interpreter Lock: Episode I - Break the Seal
Global Interpreter Lock: Episode I - Break the SealGlobal Interpreter Lock: Episode I - Break the Seal
Global Interpreter Lock: Episode I - Break the Seal
Tzung-Bi Shih
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
Roger Xia
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
Chih-Hsuan Kuo
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
Instruction Combine in LLVM
Instruction Combine in LLVMInstruction Combine in LLVM
Instruction Combine in LLVM
Wang Hsiangkai
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
Shijin Raj P
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
Mahmoud Samir Fayed
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
Doug Hawkins
 
Exploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET ImplementationExploiting the Linux Kernel via Intel's SYSRET Implementation
Exploiting the Linux Kernel via Intel's SYSRET Implementation
nkslides
 

Similar to Microkernel Development (20)

Contiki introduction II-from what to how
Contiki introduction II-from what to howContiki introduction II-from what to how
Contiki introduction II-from what to how
Dingxin Xu
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
Gowtham Reddy
 
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
katherncarlyle
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
Miller Lee
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
knight1128
 
Ive posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdfIve posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdf
deepaarora22
 
The following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdfThe following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdf
marketing413921
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
ChereCheek752
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
JungMinSEO5
 
Linux Timer device driver
Linux Timer device driverLinux Timer device driver
Linux Timer device driver
艾鍗科技
 
Other Approaches (Concurrency)
Other Approaches (Concurrency)Other Approaches (Concurrency)
Other Approaches (Concurrency)
Sri Prasanna
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens Siebert
 
Sycl 1.2 Reference Card
Sycl 1.2 Reference CardSycl 1.2 Reference Card
Sycl 1.2 Reference Card
The Khronos Group Inc.
 
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxInstruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
carliotwaycave
 
Lec05 buffers basic_examples
Lec05 buffers basic_examplesLec05 buffers basic_examples
Lec05 buffers basic_examples
Taras Zakharchenko
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
Neeraj Kaushik
 
40d5984d819aaa72e55aa10376b73bde_MIT6_087IAP10_lec12.pdf
40d5984d819aaa72e55aa10376b73bde_MIT6_087IAP10_lec12.pdf40d5984d819aaa72e55aa10376b73bde_MIT6_087IAP10_lec12.pdf
40d5984d819aaa72e55aa10376b73bde_MIT6_087IAP10_lec12.pdf
SagarYadav642223
 
PQTimer.java A simple driver program to run timing t.docx
  PQTimer.java     A simple driver program to run timing t.docx  PQTimer.java     A simple driver program to run timing t.docx
PQTimer.java A simple driver program to run timing t.docx
joyjonna282
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - Compilations
HSA Foundation
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
Rajan Kumar
 
Contiki introduction II-from what to how
Contiki introduction II-from what to howContiki introduction II-from what to how
Contiki introduction II-from what to how
Dingxin Xu
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
Gowtham Reddy
 
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
katherncarlyle
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
Miller Lee
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
knight1128
 
Ive posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdfIve posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdf
deepaarora22
 
The following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdfThe following code is an implementation of the producer consumer pro.pdf
The following code is an implementation of the producer consumer pro.pdf
marketing413921
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
ChereCheek752
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
JungMinSEO5
 
Linux Timer device driver
Linux Timer device driverLinux Timer device driver
Linux Timer device driver
艾鍗科技
 
Other Approaches (Concurrency)
Other Approaches (Concurrency)Other Approaches (Concurrency)
Other Approaches (Concurrency)
Sri Prasanna
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens Siebert
 
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxInstruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
carliotwaycave
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
Neeraj Kaushik
 
40d5984d819aaa72e55aa10376b73bde_MIT6_087IAP10_lec12.pdf
40d5984d819aaa72e55aa10376b73bde_MIT6_087IAP10_lec12.pdf40d5984d819aaa72e55aa10376b73bde_MIT6_087IAP10_lec12.pdf
40d5984d819aaa72e55aa10376b73bde_MIT6_087IAP10_lec12.pdf
SagarYadav642223
 
PQTimer.java A simple driver program to run timing t.docx
  PQTimer.java     A simple driver program to run timing t.docx  PQTimer.java     A simple driver program to run timing t.docx
PQTimer.java A simple driver program to run timing t.docx
joyjonna282
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - Compilations
HSA Foundation
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
Rajan Kumar
 
Ad

More from Rodrigo Almeida (20)

Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015
Rodrigo Almeida
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19
Rodrigo Almeida
 
As diferentes engenharias
As diferentes engenhariasAs diferentes engenharias
As diferentes engenharias
Rodrigo Almeida
 
Testing de software en instrumentos de pesar de funcionamiento no automatico ...
Testing de software en instrumentos de pesar de funcionamiento no automatico ...Testing de software en instrumentos de pesar de funcionamiento no automatico ...
Testing de software en instrumentos de pesar de funcionamiento no automatico ...
Rodrigo Almeida
 
Seguridad de sistemas embebidos para el ámbito regulado - Alejandro Bertello ...
Seguridad de sistemas embebidos para el ámbito regulado - Alejandro Bertello ...Seguridad de sistemas embebidos para el ámbito regulado - Alejandro Bertello ...
Seguridad de sistemas embebidos para el ámbito regulado - Alejandro Bertello ...
Rodrigo Almeida
 
Cryptology - Antônio Lacerda
Cryptology - Antônio LacerdaCryptology - Antônio Lacerda
Cryptology - Antônio Lacerda
Rodrigo Almeida
 
Troca de contexto segura em sistemas operacionais embarcados utilizando de té...
Troca de contexto segura em sistemas operacionais embarcados utilizando de té...Troca de contexto segura em sistemas operacionais embarcados utilizando de té...
Troca de contexto segura em sistemas operacionais embarcados utilizando de té...
Rodrigo Almeida
 
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Rodrigo Almeida
 
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Rodrigo Almeida
 
Projeto de uma controladora de drivers
Projeto de uma controladora de driversProjeto de uma controladora de drivers
Projeto de uma controladora de drivers
Rodrigo Almeida
 
Desenvolvimento de drivers para sistemas embarcados
Desenvolvimento de drivers para sistemas embarcadosDesenvolvimento de drivers para sistemas embarcados
Desenvolvimento de drivers para sistemas embarcados
Rodrigo Almeida
 
Kernel com requisitos temporais
Kernel com requisitos temporaisKernel com requisitos temporais
Kernel com requisitos temporais
Rodrigo Almeida
 
Kernel cooperativo
Kernel cooperativoKernel cooperativo
Kernel cooperativo
Rodrigo Almeida
 
Definição de processos
Definição de processosDefinição de processos
Definição de processos
Rodrigo Almeida
 
Ponteiros de Função
Ponteiros de FunçãoPonteiros de Função
Ponteiros de Função
Rodrigo Almeida
 
Conceitos de ponteiros struct e buffers
Conceitos de ponteiros struct e buffersConceitos de ponteiros struct e buffers
Conceitos de ponteiros struct e buffers
Rodrigo Almeida
 
Introdução aos sistemas operacionais embarcados
Introdução aos sistemas operacionais embarcadosIntrodução aos sistemas operacionais embarcados
Introdução aos sistemas operacionais embarcados
Rodrigo Almeida
 
Segurança de sistemas: invasões, engenharia reversa e análise de virus
Segurança de sistemas: invasões, engenharia reversa e análise de virusSegurança de sistemas: invasões, engenharia reversa e análise de virus
Segurança de sistemas: invasões, engenharia reversa e análise de virus
Rodrigo Almeida
 
Comunicação serial
Comunicação serialComunicação serial
Comunicação serial
Rodrigo Almeida
 
Utilizando um Display de LCD
Utilizando um Display de LCDUtilizando um Display de LCD
Utilizando um Display de LCD
Rodrigo Almeida
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015
Rodrigo Almeida
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19
Rodrigo Almeida
 
As diferentes engenharias
As diferentes engenhariasAs diferentes engenharias
As diferentes engenharias
Rodrigo Almeida
 
Testing de software en instrumentos de pesar de funcionamiento no automatico ...
Testing de software en instrumentos de pesar de funcionamiento no automatico ...Testing de software en instrumentos de pesar de funcionamiento no automatico ...
Testing de software en instrumentos de pesar de funcionamiento no automatico ...
Rodrigo Almeida
 
Seguridad de sistemas embebidos para el ámbito regulado - Alejandro Bertello ...
Seguridad de sistemas embebidos para el ámbito regulado - Alejandro Bertello ...Seguridad de sistemas embebidos para el ámbito regulado - Alejandro Bertello ...
Seguridad de sistemas embebidos para el ámbito regulado - Alejandro Bertello ...
Rodrigo Almeida
 
Cryptology - Antônio Lacerda
Cryptology - Antônio LacerdaCryptology - Antônio Lacerda
Cryptology - Antônio Lacerda
Rodrigo Almeida
 
Troca de contexto segura em sistemas operacionais embarcados utilizando de té...
Troca de contexto segura em sistemas operacionais embarcados utilizando de té...Troca de contexto segura em sistemas operacionais embarcados utilizando de té...
Troca de contexto segura em sistemas operacionais embarcados utilizando de té...
Rodrigo Almeida
 
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Rodrigo Almeida
 
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Troca de contexto segura em sistemas operacionais embarcados utilizando técni...
Rodrigo Almeida
 
Projeto de uma controladora de drivers
Projeto de uma controladora de driversProjeto de uma controladora de drivers
Projeto de uma controladora de drivers
Rodrigo Almeida
 
Desenvolvimento de drivers para sistemas embarcados
Desenvolvimento de drivers para sistemas embarcadosDesenvolvimento de drivers para sistemas embarcados
Desenvolvimento de drivers para sistemas embarcados
Rodrigo Almeida
 
Kernel com requisitos temporais
Kernel com requisitos temporaisKernel com requisitos temporais
Kernel com requisitos temporais
Rodrigo Almeida
 
Definição de processos
Definição de processosDefinição de processos
Definição de processos
Rodrigo Almeida
 
Conceitos de ponteiros struct e buffers
Conceitos de ponteiros struct e buffersConceitos de ponteiros struct e buffers
Conceitos de ponteiros struct e buffers
Rodrigo Almeida
 
Introdução aos sistemas operacionais embarcados
Introdução aos sistemas operacionais embarcadosIntrodução aos sistemas operacionais embarcados
Introdução aos sistemas operacionais embarcados
Rodrigo Almeida
 
Segurança de sistemas: invasões, engenharia reversa e análise de virus
Segurança de sistemas: invasões, engenharia reversa e análise de virusSegurança de sistemas: invasões, engenharia reversa e análise de virus
Segurança de sistemas: invasões, engenharia reversa e análise de virus
Rodrigo Almeida
 
Utilizando um Display de LCD
Utilizando um Display de LCDUtilizando um Display de LCD
Utilizando um Display de LCD
Rodrigo Almeida
 
Ad

Recently uploaded (20)

Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 

Microkernel Development

  • 1. Microkernel development: from project to implementation Rodrigo Maximiano Antunes de Almeida E-mail: rmaalmeida@gmail.com Twitter: @rmaalmeida Universidade Federal de Itajubá
  • 2. Creative Commons License The work ” Microkernel development: from project to implementation ” of Rodrigo Maximiano Antunes de Almeida was licensed with Creative Commons 3.0 – Attribution – Non Commercial – Share Alike license . Additional permission can be given by the author through direct contact using the e-mail: rmaalmeida@gmail.com
  • 3. “ I reinvented the wheel last week. I sat down and deliberately coded something that I knew already existed, and had probably also been done by many many other people. In conventional programming terms, I wasted my time. But it was worthwhile, and what's more I would recommend almost any serious programmer do precisely the same thing.” James Hart
  • 4. //today topics void main (void){ //variable declaration kernel_project ( 1 ); //initialization concepts ( 2 ); //hard-work microkernel ( 3 ); }
  • 5. void kernel_project (float i ){ what_is_a_kernel ( 1.1 ); alternatives ( 1.2 ); kernel_design_decisions ( 1.3 ); }
  • 7. kernel_project ( 1 ); Kernel tasks: Manage and coordinate the processes execution using “some criteria” Manage the free memory and coordinate the processes access to it Intermediate the communication between the hardware drivers and the processes
  • 8. kernel_project ( 1 ); Alternatives Windows Embedded Compact® VxWorks® X RTOS® uClinux FreeRTOS BRTOS
  • 9. kernel_project ( 1 ); Monolithic kernel versus microkernel Linus Torvalds and Andrew Tanenbaum
  • 10. kernel_project ( 1 ); Kernel design decisions I/O devices management Process management System safety
  • 11. kernel_project ( 1 ); Our decisions: Microkernel Non-preemptive Cooperative No memory management Process scheduled based on timer Isolate drivers using a controller
  • 12. void concepts (float i ){ function_pointers ( 2.1 ); temporal_conditions ( 2.2 ); void_pointers ( 2.3 ); }
  • 13. concepts ( 2 ); function_pointers ( 2.1 );
  • 14. concepts ( 2 ); Function pointers Work almost as a normal pointer Hold the address of a function start point instead the address of a variable The compiler need no known the function signature to pass the correct parameters and the return value. Awkard declaration (it is best to use a typedef)
  • 15. concepts ( 2 ); //defining the type pointerTest //it is a pointer to function that: // receives no parameter // returns no parameter typedef void (* pointerTest )(void); //Function to be called void nop (void){ __asm NOP __endasm } //creating an pointerTest variable; pointerTest foo ; foo = nop ; (* foo )(); //calling the function via pointer
  • 16. concepts ( 2 ); temporal_conditions ( 2.2 );
  • 17. concepts ( 2 ); In the majority part of embedded systems, we need to guarantee that a function will be executed in a certain frequency. Some systems may even fail if these deadlines are not met.
  • 18. concepts ( 2 ); To implement temporal conditions: There must be a tick event that occurs with a precise frequency The kernel must be informed of the execution frequency needed for each process. The sum of process duration must “fit” within the processor available time.
  • 19. concepts ( 2 ); 1 st condition: Needs an internal timer that can generate an interrupt. 2 nd condition: Add the information for each process when creating it 3 rd condition: Test, test and test. If fail, change chip first, optimize only on last case
  • 20. concepts ( 2 ); Scheduling processes: Using a finite timer to schedule will result in overflow Example: scheduling 2 processes for 10 and 50 seconds ahead.
  • 21. concepts ( 2 ); And if two process are to be called in the same time?
  • 22. concepts ( 2 ); Question: From the timeline above (only the timeline) is P2 late or it was scheduled to happen 55(s) from now?
  • 23. concepts ( 2 ); Solution: Use a downtime counter for each process instead of setting a trigger time. Problem: Each counter must be decremented in the interrupt subroutine. Is it a problem for your system?
  • 24. concepts ( 2 ); void_pointers ( 2.3 );
  • 25. concepts ( 2 ); Void pointers Abstraction that permits to the programmer to pass parameters with different types to the same function. The function which is receiving the parameter must know how to deal with it It can not be used without proper casting!
  • 26. concepts ( 2 ); char * name = &quot;Paulo&quot; ; double weight = 87.5 ; unsigned int children = 3 ; void main (void){ //its not printf, yet. print ( 0 , & name ); print ( 1 , & weight ); print ( 2 , & children ); }
  • 27. concepts ( 2 ); void print (int option ; void * parameter ){ switch( option ){ case 0 : printf ( &quot;%s&quot; ,(char*) parameter ); break; case 1 : printf ( &quot;%f&quot; ,*((double*) parameter )); break; case 2 : printf ( &quot;%d&quot; ,*((unsigned int*) parameter )); break; } }
  • 28. void microkernel (float i ){ init_kernel ( 3.0 ); for(int i = 1 ; i < 4 ; i ++;) { kernel_example ( 3 + i / 10 ); } }
  • 29. microkernel ( 3 ); init_kernel ( 3.0 );
  • 30. microkernel ( 3 ); We will present the examples using a minimum of hardware or platform specific commands. Unfortunately some actions (specifically the timer) needs to access the hardware. We'll present a brief resume about our platform and some custom headers.
  • 31. microkernel ( 3 ); //CONFIG.H code char at 0x300000 CONFIG1L = 0x01 ; // No prescaler used code char at 0x300001 CONFIG1H = 0x0C ; // HS: High Speed Cristal code char at 0x300003 CONFIG2H = 0x00 ; // Disabled-Controlled by SWDTEN bit code char at 0x300006 CONFIG4L = 0x00 ; // Disabled low voltage programming //INT.H void InicializaInterrupt (void); //TIMER.H char FimTimer (void); void AguardaTimer (void); void ResetaTimer (unsigned int tempo ); void InicializaTimer (void); //BASICO.H (only part of it) #define SUCCESS 0 #define FAIL 1 #define REPEAT 2 //bit functions #define BitFlp ( arg , bit ) (( arg ) ^= ( 1 << bit )) //special register information #define PORTD (*(volatile __near unsigned char*) 0xF83 ) #define TRISC (*(volatile __near unsigned char*) 0xF94 )
  • 32. microkernel ( 3 ); //first implementation kernel_example ( 3 + 1 / 10 );
  • 33. microkernel ( 3 ); In this first example we will build the main part of our kernel. It should have a way to store which functions are needed to be executed and in which order. This will be done by a static vector of pointers to function //pointer function declaration typedef void(* ptrFunc )(void); //process pool static ptrFunc pool [ 4 ];
  • 34. microkernel ( 3 ); Each process is a function with the same signature of ptrFunc void tst1 (void){ printf ( &quot;Process 1\n&quot; ); } void tst2 (void){ printf ( &quot;Process 2\n&quot; ); } void tst3 (void){ printf ( &quot;Process 3\n&quot; ); }
  • 35. microkernel ( 3 ); The kernel itself consists of three functions: One to initialize all the internal variables One to add a new process One to execute the main kernel loop //kernel internal variables ptrFunc pool [ 4 ]; int end ; //kernel function's prototypes void kernelInit (void); void kernelAddProc (ptrFunc newFunc ); void kernelLoop (void);
  • 36. microkernel ( 3 ); //kernel function's implementation void kernelInit (void){ end = 0 ; } void kernelAddProc (ptrFunc newFunc ){ if ( end < 4 ){ pool [ end ] = newFunc ; end ++; } }
  • 37. microkernel ( 3 ); //kernel function's implementatio n void kernelLoop (void){ int i ; for(;;){ //cycle through the processes for( i = 0 ; i < end ; i ++){ (* pool [ i ])(); } } }
  • 38. microkernel ( 3 ); //main loop void main (void){ kernelInit (); kernelAddProc ( tst1 ); kernelAddProc ( tst2 ); kernelAddProc ( tst3 ); kernelLoop (); }
  • 39. microkernel ( 3 ); Simple?
  • 40. microkernel ( 3 ); //second implementation //circular buffer and struct added kernel_example ( 3 + 2 / 10 );
  • 41. microkernel ( 3 ); The only struct field is the function pointer. Other fields will be added latter. The circular buffer open a new possibility: A process now can state if it wants to be rescheduled or if it is a one-time run process In order to implement this every process must return a code. This code also says if there was any error in the process execution
  • 42. microkernel ( 3 ); //return code #define SUCCESS 0 #define FAIL 1 #define REPEAT 2 //function pointer declaration typedef char(* ptrFunc )(void); //process struct typedef struct { ptrFunc function ; } process ; process pool [ POOL_SIZE ];
  • 43. microkernel ( 3 ); char kernelInit (void){ start = 0 ; end = 0 ; return SUCCESS ; } char kernelAddProc (process newProc ){ //checking for free space if ( (( end + 1 )% POOL_SIZE ) != start ){ pool [ end ] = newProc ; end = ( end + 1 )% POOL_SIZE ; return SUCCESS ; } return FAIL ; }
  • 44. microkernel ( 3 ); void kernelLoop (void){ int i = 0 ; for(;;){ //Do we have any process to execute? if ( start != end ){ printf ( &quot;Ite. %d, Slot. %d: &quot; , i , start ); //check if there is need to reschedule if ((*( pool [ start ]. Func ))() == REPEAT ){ kernelAddProc ( pool [ start ]); } //prepare to get the next process; start = ( start + 1 )% POOL_SIZE ; i ++; // only for debug; } } }
  • 45. microkernel ( 3 ); //vector of structs process pool [ POOL_SIZE ]; // pool[i] // pool[i].func // *(pool[i].func) // (*(pool[i].func))() //vetor of pointers for struct process* pool [ POOL_SIZE ]; // pool[i] // pool[i].func // pool[i]->func // pool[i]->func()
  • 46. microkernel ( 3 ); void kernelLoop (void){ int i = 0 ; for(;;){ //Do we have any process to execute? if ( start != end ){ printf ( &quot;Ite. %d, Slot. %d: &quot; , i , start ); //check if there is need to reschedule if ( pool [ start ]-> Func () == REPEAT ){ kernelAddProc ( pool [ start ]); } //prepare to get the next process; start = ( start + 1 )% POOL_SIZE ; i ++; // only for debug; } } }
  • 47. microkernel ( 3 ); Presenting the new processes void tst1 (void){ printf ( &quot;Process 1\n&quot; ); return REPEAT ; } void tst2 (void){ printf ( &quot;Process 2\n&quot; ); return SUCCESS ; } void tst3 (void){ printf ( &quot;Process 3\n&quot; ); return REPEAT ; }
  • 48. microkernel ( 3 ); void main (void){ //declaring the processes process p1 = { tst1 }; process p2 = { tst2 }; process p3 = { tst3 }; kernelInit (); //Test if the process was added successfully if ( kernelAddProc ( p1 ) == SUCCESS ){ printf ( &quot;1st process added\n&quot; );} if ( kernelAddProc ( p2 ) == SUCCESS ){ printf ( &quot;2nd process added\n&quot; );} if ( kernelAddProc ( p3 ) == SUCCESS ){ printf ( &quot;3rd process added\n&quot; );} kernelLoop (); }
  • 49. microkernel ( 3 ); Notes: Only process 1 and 3 are repeating The user don't notice that the pool is finite* Console Output: --------------------------- 1st process added 2nd process added 3rd process added Ite. 0, Slot. 0: Process 1 Ite. 1, Slot. 1: Process 2 Ite. 2, Slot. 2: Process 3 Ite. 3, Slot. 3: Process 1 Ite. 4, Slot. 0: Process 3 Ite. 5, Slot. 1: Process 1 Ite. 6, Slot. 2: Process 3 Ite. 7, Slot. 3: Process 1 Ite. 8, Slot. 0: Process 3 ... ---------------------------
  • 50. microkernel ( 3 ); //third implementation //time conditions added kernel_example ( 3 + 3 / 10 );
  • 51. microkernel ( 3 ); The first modification is to add one counter to each process //process struct typedef struct { ptrFunc function ; int period ; int start ; } process ;
  • 52. microkernel ( 3 ); We must create an function that will run on each timer interrupt updating the counters void isr (void) interrupt 1 { unsigned char i ; i = ini ; while( i != fim ){ if(( pool [ i ]. start )>( MIN_INT )){ pool [ i ]. start --; } i = ( i + 1 )% SLOT_SIZE ; } }
  • 53. microkernel ( 3 ); The add process function will be the responsible to initialize correctly the fields char AddProc (process newProc ){ //checking for free space if ( (( end + 1 )% SLOT_SIZE ) != start ){ pool [ end ] = newProc ; //increment start timer with period pool [ end ]. start += newProc . period ; end = ( end + 1 )% SLOT_SIZE ; return SUCCESS ; } return FAIL ; }
  • 54. microkernel ( 3 ); if ( start != end ){ //Finding the process with the smallest start j = ( start + 1 )% SLOT _ SIZE ; next = start ; while ( j != end ){ if ( pool [ j ]. start < pool [ next ]. start ){ next = j ; } j = ( j + 1 )% SLOT_SIZE ; } //exchanging positions in the pool tempProc = pool [ next ]; pool [ next ] = pool [ start ]; pool [ start ] = tempProc ; while( pool [ start ]. start > 0 ){ } //great place to use low power mode if ( (*( pool [ ini ]. function ))() == REPEAT ){ AddProc (&( vetProc [ ini ])); } ini = ( ini + 1 )% SLOT_SIZE ; }
  • 55. //today topics void main (void){ //variable declaration kernel_project ( 1 ); //initialization concepts ( 2 ); //hard-work microkernel ( 3 ); }
  • 56. “ Don't Reinvent The Wheel, Unless You Plan on Learning More About Wheels” Jeff Atwood Microkernel development: from project to implementation Rodrigo Maximiano Antunes de Almeida E-mail: rmaalmeida@gmail.com Twitter: @rmaalmeida Universidade Federal de Itajubá
  翻译: