Đang chuẩn bị liên kết để tải về tài liệu:
programming LEGO MINDSTORMS phần 8
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Nhiệm vụ có thể chạy trên máy tính trong thời gian thực gần (có một khoảng thời gian đáng chú ý). Chúng ta có thể thêm | leJOS Internals Chapter 8 307 that runs in a rather short loop. For larger programs with several threads reaction time is more likely to be on the order of 100ms. A thread that does not yield the processor itself currently gets a time slice of 20ms but this can be changed in platform_config.h via the TICKS_PER_TIME_SLICE constant where a tick equals one millisecond. The ticks are generated by the OCIA interrupt that is activated every millisecond and which also controls motors A D conversion for sensors sounds and the global millisecond timer that is read by System .currentTimeMillis . As specified by the Java Language Specification threads are scheduled strictly according to their priority. As long as high-priority threads want to run all lower priority threads must wait. Threads of the same priority are scheduled in a round-robin fashion. To achieve faster reaction times than those possible in Java code you can add code to the virtual machine itself.This is facilitated by using one of the hooks into the byte code interpreter provided by the virtual machine instruction_hook Called before every instruction executed by the VM. Beware that using it will slow down leJOS considerably. tick_hook Called at least every millisecond before the next instruction is executed but possibly more often if there is scheduling activity.This has a relatively low impact on speed. idle_hook Called when no thread wants to run. switch_thread_hook Called after every call of the scheduler. These hook into the main interpreter loop in vmsrc interpreter.c and their platform-specific values are defined in rcx_impl platform_hooks.h and unix_impl platform_hooks.h.The leJOS firmware currently uses only tick_hook for sensor reading. The sensor values need to be processed on each A D-conver-sion which happens every 3ms otherwise rotation sensors and pulse- and edgecounting on touch sensors will not work properly. To avoid this a single transitional value leads to a miscount for the rotation sensor