deep

a Cross Development Platform for Java

User Tools

Site Tools


runtime_library:os:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
runtime_library:os:start [2015/04/04 08:19] ursgrafruntime_library:os:start [2021/12/27 15:27] (current) – [System Sanity Checks] ursgraf
Line 1: Line 1:
 ====== Operating System ===== ====== Operating System =====
-You can program the processor either using interrupts in a foreground/background system or means of an operating system. Some classes will be linked and loaded in either case. This is true for the class //Kernel// for basic initializations, the class //Heap// for dynamic memory allocation and the classes for exception handling. \\ +You can program the processor either using interrupts in a foreground/background system or means of an operating system. Some classes will be linked and loaded in either case. This is true for the class ''Kernel'' for basic initializations, the class ''Heap'' for dynamic memory allocation and the classes for exception handling. \\ 
-When choosing an operating system you can select a simple, robust and very efficient non-preemtive tasking system (class //Task//). The very popular MicroC/OSII will be also available on request. +When choosing an operating system you can select a simple, robust and very efficient non-preemtive tasking system (class ''Task''). The very popular MicroC/OSII will be also available on request. 
-For any operating system the minimum task period is limited to the order of milliseconds. For fast control applications you can use the decrementer as a fast running timer and produce exceptions at a very high frequency.+The minimum task period is limited to one millisecond. For fast control applications you can use the decrementer on the PowerPC architecture or on the Zynq7000 platform as a fast running timer and produce exceptions at a very high frequency.
 The basic modules are all written in Java. All the necessary hardware resources can be accessed through special built-in methods. The basic modules are all written in Java. All the necessary hardware resources can be accessed through special built-in methods.
  
 ===== Class Constructors and the main() Method ===== ===== Class Constructors and the main() Method =====
-When starting up a Java system has to call the static constructor of every class loaded and finally calls the main method. Our system does not support a main method. This has the advantage that you can have as many root level classes (or application classes) as you like. In IDE (to be done) you can see how to build several root level classes into the same project. +When starting up a general java systemthe static constructors of every class must be loaded and finally the main method has to be called. Our system does not support a main method. This has the advantage that you can have as many root level classes (or application classes) as you like. In [[crosscompiler:deep_projects#rootclasses|deep projects]] you can see how to build several root level classes into the same project. 
 An example of using a class constructor is shown in the following section. An example of using a class constructor is shown in the following section.
 ===== Non-Preemptive Tasking System =====  ===== Non-Preemptive Tasking System ===== 
-The class mpc555.Task offers a very efficient non-preemtive scheduler. The basic timing resolution is 1ms. You can create and install as many tasks as you like. Care must be taken that each of those tasks terminates after a reasonably short time span. Control is than taken over by the scheduler which chooses the next available task in a round-robin fashion. \\ +The class ''Task'' offers a very efficient non-preemtive scheduler. The basic timing resolution is 1ms. You can create and install as many tasks as you like. Care must be taken that each of those tasks terminates after a reasonably short time span. Control is then taken over by the scheduler which chooses the next available task in a round-robin fashion. \\ 
-There are two types of tasks: ready tasks have a period of 0. That is they are scheduled as quickly as possible. There repetition frequency depends highly on the processor load and the task code itself. Periodic tasks have a non-zero period. They get scheduled after the system time passes the assigned period of the task.\\+There are two types of tasks: ready tasks have a period of 0. That isthey are scheduled as quickly as possible. Their repetition frequency depends highly on the processor load and the task code itself. Periodic tasks have a non-zero period. They get scheduled after the system time passes the assigned period of the task.\\
 The following code shows how to create and install a task. The following code shows how to create and install a task.
  
 <code java> <code java>
-public class TestTask extends Task{+public class TestTask extends Task {
  
- public void action () { +  public void action () { 
- // put task code here +    // put task code here 
- }+  }
   
- static {  +  static {  
- Task task1 = new TestTask();  +    Task task1 = new TestTask();  
- task1.period = 500; // call twice per second +    task1.period = 500; // call twice per second 
- Task.install(task1); +    Task.install(task1); 
- }+  }
 } }
 </code> </code>
  
 ===== Interrupts ===== ===== Interrupts =====
-The mpc555 has no hardware priorization scheme when dealing with interrupts. Also there is no interrupt vectoring. All the potential internal and external interrupt sources get vectored to the same memory location and are dealt with by a software scheduler. You have to assign a level to each of the interrupts. A low level means a high priority. To achieve highest efficiency interrupt nesting is switched off. That makes it necessary to write small interrupt routines.+A processor might have some sort of a hardware priorization scheme when dealing with interrupts. Some of the potential internal and external interrupt sources use vectoring or get vectored to the same memory location and are dealt with by a software scheduler. You have to assign a priority level to each of the interrupts. A low level means a high priority. In order to achieve highest efficiencyinterrupt nesting is switched off. That makes it necessary to write small interrupt service routines. Further, never allocate objects within an interrupt routine or in a method called by an interrupt routine, because the heap allocation methods are not thread safe for efficiency reasons.
  
-==== Internal Interrupts ==== +==== Interrupts in the ARM Architecture ==== 
-Internal interrupts are all those who are caused by built-in peripheral modules, like TPU, ADC and communication interfaces. You can use them by extending the class Interrupt, write your own action-Method and install this object into the interrupt scheduler by calling //install//. As parameter you have to indicate the interrupt object together with a level which has to be between 0 and 7. You can install any number of interrupt objects with the same level.+=== Zynq7000 Interrupts === 
 +A Zynq7000 processor has private peripheral and shared peripheral interrupts and assigns each peripheral a interrupt number, see the [[https://wiki.bu.ost.ch/infoportal/embedded_systems/zynq7000/start|Zynq 7000 Technical Reference Manual]], table 7-4.   
 + 
 +<code java> 
 +public class IntTest extends IrqInterrupt{ 
 + 
 +  public void action() { 
 +    // put your code here 
 +    US.PUT4(IsrReg, (1 << BitNum)); // clear interrupt status bit 
 +  } 
 + 
 +  static { 
 +    IntTest int = new IntTest();  
 +    IrqInterrupt.install(int, num);  // num must be equal to the assigned number for this peripheral 
 +  } 
 +
 +</code> 
 + 
 +==== Interrupts in the PowerPC Architecture ==== 
 +=== Internal Interrupts === 
 +Internal interrupts are all those who are caused by built-in peripheral modules, like time processor units, ADC and communication interfaces. You can use them by extending the class //Interrupt//, write your own //action// method and install this object into the interrupt scheduler by calling //install//. As parameter you have to indicate the interrupt object together with a level which has to be between 0 and 7. You can install any number of interrupt objects with the same level.
  
 <code java> <code java>
 public class IntTest extends Interrupt { public class IntTest extends Interrupt {
  
- public void action() { +  public void action() { 
- // put your code here +    // put your code here 
- }+  }
  
- static { +  static { 
- IntTest int = new IntTest();  +    IntTest int = new IntTest();  
- int.enableRegAdr = registername; int.enBit = bitnumber; +    int.enableRegAdr = registername; int.enBit = bitnumber; 
- int.flagRegAdr = registername; int.flag = bitnumber; +    int.flagRegAdr = registername; int.flag = bitnumber; 
- Interrupt.install(int, 5, true); +    Interrupt.install(int, 5, true); 
- }+  }
 } }
 </code> </code>
  
-==== External Interrupts ====+=== External Interrupts (mpc555)===
 The mpc555 offers 8 external interrupt inputs. They are named IRQ0 to IRQ7. In order to use them you have to extend the class Interrupt, overwrite its action method and call the method //install()//. As parameters you have to give the newly allocated interrupt and the number of the interrupt pin which corresponds to the interrupt level. Care must be taken not to assign more than one interrupt objects to the same interrupt pin. The mpc555 offers 8 external interrupt inputs. They are named IRQ0 to IRQ7. In order to use them you have to extend the class Interrupt, overwrite its action method and call the method //install()//. As parameters you have to give the newly allocated interrupt and the number of the interrupt pin which corresponds to the interrupt level. Care must be taken not to assign more than one interrupt objects to the same interrupt pin.
  
Line 56: Line 76:
 public class ExtIntTest extends Interrupt { public class ExtIntTest extends Interrupt {
  
- public void action() { +  public void action() { 
- // put your code here +    // put your code here 
- }+  }
  
- static { +  static { 
- ExtIntTest int5 = new ExtIntTest();  +    ExtIntTest int5 = new ExtIntTest();  
- Interrupt.install(int5, 5, false); +    Interrupt.install(int5, 5, false); 
- }+  }
 } }
 </code> </code>
Line 69: Line 89:
 The voltage level on the external interrupt pins 5, 6 and 7 also select the operating when starting the device up. Do not override these levels during start-up! The voltage level on the external interrupt pins 5, 6 and 7 also select the operating when starting the device up. Do not override these levels during start-up!
  
-==== Switch off Interrupts Globally ====+=== Switch off Interrupts Globally ===
 All the external and internal interrupts can be switched off and on again, e.g. for accessing shared resources. Keep the switch-off time as low as possible. This should always be done in the following manner. All the external and internal interrupts can be switched off and on again, e.g. for accessing shared resources. Keep the switch-off time as low as possible. This should always be done in the following manner.
  
 <code java> <code java>
 void MyExampleMethod () { void MyExampleMethod () {
- ... +  ... 
- US.PUTSPR(EID, 0); // switch off interrupts globally +  US.PUTSPR(EID, 0); // switch off interrupts globally 
- ... // critical section +  ... // critical section 
- US.PUTSPR(EIE, 0); // interrupts reenabled  +  US.PUTSPR(EIE, 0); // interrupts reenabled  
- ...+  ...
 } }
 </code> </code>
  
-==== Decrementer Exceptions ====+=== Decrementer Exceptions ===
 The decrementer is a timer with a resolution of 1μs. Therefore you can use it for very fast control applications. Simply extend the class decrementer and overwrite the action method with your specific code. Make sure to set the period in μs to some meaningful value. You then have to call the //install// method. The decrementer is a timer with a resolution of 1μs. Therefore you can use it for very fast control applications. Simply extend the class decrementer and overwrite the action method with your specific code. Make sure to set the period in μs to some meaningful value. You then have to call the //install// method.
  
 <code java> <code java>
 public class DecrementerTest extends Decrementer { public class DecrementerTest extends Decrementer {
- static int count;+  static int count;
  
- public void action() { +  public void action() { 
- // put your code here +    // put your code here 
- }+  }
  
- static { +  static { 
- DecrementerTest d = new DecrementerTest(); +    DecrementerTest d = new DecrementerTest(); 
- d.decPeriodUs = 1000000; // period is 1 s +    d.decPeriodUs = 1000000; // period is 1 s 
- Decrementer.install(d); +    Decrementer.install(d); 
- }+  }
 } }
 </code> </code>
Line 107: Line 127:
  
 =====System Sanity Checks ===== =====System Sanity Checks =====
-  The stack size is set by the configuration. In order to check, whether this size is enough at all times for a running system, you can call a target command //ch.ntb.inf.deep.runtime.mpc555.Kernel.checkStack//. If the stack size was ever bigger than the maximum stack size this check fails and the LED on the 555 board starts blinking. +  The stack size is set by the configuration. In order to check, whether this size is enough at all times for a running system, you can call a target command in your kernel, e.g//org.deepjava.runtime.mpc555.Kernel.checkStack//\\ If the stack size was ever bigger than the maximum stack size this check fails and the signalling LED on the board starts blinking, see [[runtime_library:exceptions:start#signaling_with_led|Signaling with LED]]
-  The heap manager includes an automatic garbage collection. If the heap gets too fragmented or to large chunks of heap memory are requested and no free block can be found, the LED on the 555 board starts blinking and programm excecution stops.+  The heap manager includes an automatic garbage collection. If the heap gets too fragmented or to large chunks of heap memory are requested and no free block can be found, the signaling LED on the board starts blinking and program execution stops, see [[runtime_library:exceptions:start#signaling_with_led|Signaling with LED]].
  
runtime_library/os/start.1428128355.txt.gz · Last modified: 2016/02/25 13:33 (external edit)