What is Round Robin DNS?

Round Robin (Chinese translation for round-robin scheduling) is a calculation method for scheduling different servers by resolving a domain name to multiple IP addresses in turn in a round-robin manner.

Round Robin

When the system was implemented, we introduced an additional condition. When the weight of the server is zero, it means that the server is unavailable and not scheduled. The purpose of this is to cut the server out of service (such as shielding server failure and system maintenance), while maintaining consistency with other weighting algorithms. Therefore, the algorithm needs to be changed accordingly. Its algorithm flow is as follows:
Polling scheduling algorithm flow
Suppose there is a set of servers S = {S0, S1,, Sn-1}, and an indicator variable i represents the last selected
Server, W (Si) represents the weight of server Si. The variable i is initialized to n-1, where n> 0.
j = i;
do {
j = (j + 1) mod n;
if (W (Sj)> 0) {
i = j;
return Si;
}
} while (j! = i);
return NULL;
The polling scheduling algorithm assumes that all servers have the same processing performance, regardless of the server's current connections and response speed. The algorithm is relatively simple, and it is not suitable for situations with different processing performance in the server group, and when the request service time changes greatly, the polling scheduling algorithm easily leads to load imbalance between servers.
Although the Round-Robin DNS method also resolves a domain name to multiple IP addresses in a polling manner, the scheduling granularity of the round-robin DNS method is based on each
RTX51 Tiny can be customized according to the user's application.
Configuration
RTX51 Tiny must be configured according to your embedded application. All configuration parameters are in the configuration file CONF_TNY.A51. This file is located in the \ KEIL \ C51 \ RTXTINY2 \ folder. You can do the following things by selecting the settings in the file.
Specify the clock tick interrupt register group
Specify clock tick interval (multiple 8051 machine cycles)
Specify the user code to be executed in the clock tick interrupt
Specify round-robin overflow time
Enable round-robin task switching
Specify that your application contains long interruptions
Specify whether code banking is used
Define the top of the stack for RTX51 Tiny
Instruction requires minimal stack space
Execute code when specified stack error
Define idle task operations
The default configuration of CONF_TNY.A51 is included in RTX51 Tiny's library. However, to use the configuration file in use, you must copy the configuration file to your project folder and add it to the project.
To customize the configuration of RTX51 Tiny, you must change the setting of CONF_TNY.A51
note:
If a configuration file is not included in the project, the default configuration file will be automatically included in the project. Profiles stored in hindsight libraries may have the opposite effect on your application
Hardware clock
The following parameters specify how to configure the accessory clock for RTX51 Tiny
INT_REGBANK Specifies the register group used by the RTX51 Tiny clock interrupt. The default is register group 1.
INT_CLOCK specifies the period data before the clock generates an interrupt. This value ranges from 1000 to 65535. Smaller values generate interrupts faster. This value is used to calculate the clock reload value (65536-INT_CLOCK). The default value is 10000.
HW_TIMER_CODE is a macro definition, which is used to specify the code executed in the RTX51 Tiny clock tick interrupt. The default setting of this macro is to return from interrupt (RETI) such as:
HW_TIMER_CODE MACRO
; Empty Macro by default
RETI
ENDM
Round-robin
Round-robin switching is enabled by default. The following parameters are used to set the round-robin switching time or disable round-robin switching.
TIMESHARING Specifies the number of RTX51 Tiny clock ticks that the task will execute before performing a round-robin switch. When this value is 0, Round-robin switching is disabled. The default value is 5 clock ticks.
Long interruption
In general, interrupt service routines (ISRs) are required to be completed quickly. Sometimes, the interrupt service routine may take a long time to execute. If a high-priority interrupt takes longer than the tick interval, the RTX51 clock interrupt may be interrupted by this higher-priority interrupt and re-entered by a later RTX51 clock interrupt.
If a high-priority interrupt that takes a long time to run is used, you should consider reducing the workload of the interrupt service routine, changing the RTX51 clock tick rate, or using the following configuration.
LONG_USR_ISR Specifies whether to use interrupts that take longer than the clock tick. When this value is set to 1, RTX51 Tiny will include the code that protects the RTX51 Tiny clock tick interrupt re-entry. This value defaults to 0
Code banking
The following settings specify whether code banking is used in the RTX51 Tiny application
CODE_BANKING Set to 1 to use code banking. Cleared to 0 to not use code banking. The default value is 0
Note: 2.2 or higher of L51_BANK.A51 requires RTX51 Tiny program to use code banking
Stack
There are several configuration options for the stack. The following parameters specify the size of the memory space used for the stack and the minimum space for the stack. Use a macro to specify which piece of code to execute when the CPU's stack space is insufficient.
RAMTOP specifies the top address of the stack. It is best not to modify this address unless you use IDATA variables on the stack.
FREE_STACK specifies the minimum free space on the stack. When switching to a task, if the RTX51 Tiny detects that the available stack space is less than this value, the STACK_ERROR macro will be executed. Set to 0 to disable stack checking. The default value is 20 bytes.
STACK_ERROR is a macro that represents a piece of code that is executed when a stack error occurs. The default code for this macro is to disable interrupts and enter an infinite loop. Such as
STACK_ERROR MACRO
CLR EA; disable interrupts
SJMP $; endless loop if stack space is exhausted
ENDM
Idle task
When there are no tasks to execute, RTX51 Tiny executes idle tasks. Idle tasks do nothing, just wait for the RTX51 Tiny clock tick to interrupt and switch to another ready task. The following parameters are used to configure different aspects of the RTX51 Tiny idle task
CPU_IDLE This is a macro that represents code executed in idle tasks. The default instruction is to set the idle mode bit of the PCON register. This saves energy by suspending the program. Such as
CPU_IDLE MACRO
ORL PCON, # 1; set 8051 CPU to IDLE
ENDM
CPU_IDLE_CODE Specifies whether the CPU_IDLE macro executes in idle tasks. The default value is 0, so idle tasks will not include the CPU_IDLE macro
Library file
RTX51 Tiny includes two library files
RTX51TNY.LIB is used for non-banking RTX51 Tiny programs
RTX51BT.LIB is used for code-banking RTX51 Tiny programs.
The RTXTINY2.PRJ project found in the \ KEIL \ C51 \ RTXTINY2 \ SOURCECODE \ folder is used to build these two libraries.
Note: You do not need to explicitly include these two files in your application. These files are included automatically if you use Vision2 IDE or command-line linker.
If you want to build the RTX51 Tiny library, the default configuration file will be added. If you do not explicitly include a configuration file, the default configuration file is included. Subsequent changes to the configuration file will have unexpected effects on use.
optimization
You can optimize the RTX51 Tiny program in the following ways
If possible, disable round-robin task switching. Round-robin requires 13 bytes of stack space to store the task address and all registers. If task switching is triggered by the RTX51 Tiny runtime library (such as os_wait or os_switch_task), these spaces are not needed.
Use os_wait instead of round-robin to run out of time to switch tasks. These will increase the response time of the system and the response speed of the task
Avoid setting the interrupt rate of the system clock tick too high. Setting the clock overflow time shorter increases the number of clock ticks per second but reduces the available time for each task, as each clock tick interrupt will use 100-200 cycles to run. Therefore, it is necessary to set the elapsed time small enough to reduce the side effects caused by the interruption of the clock tick.
Using RTX51 Tiny
To use RTX51 Tiny, you must successfully generate RTX51 programs and compile and link them
Programming
Define RTX51 program using keyword _task_
Use RTX51 Tiny's kernel with RTX51TNY.H template
Include file
RTX51 Tiny only needs to include a file RTX51TNY.H. All runtime library constants are defined in this header file. It can be included in the following ways:
#include <rtx51tny.h>
Programming Guide
The following rules must be followed when programming with RTX51 Tiny:
Include file rtx51tny.h
Don't create C main function, RTX51 Tiny has its own main function
The program creates at least one task
The program must call the RTX51 Tiny runtime library (such as os_wait) at least once. Otherwise, the connector will not include the RTX51 Tiny library
Task 0 is the first task performed by your program. Must call os_create_task function in task 0 to run other tasks
The task never returns or exits. The task must use while (1) or similar structure. Use os_delete_task function to suspend a task
RTX51 Tiny must be specified in Vision2 or in the link compile command line
Define tasks
Real-time or multi-tasking applications consist of one or more tasks that perform specific functions. RTX51 Tiny supports up to 16 tasks
The task must be a C function declared with _task_, and the return value and parameters must be void types, such as
void func (void) _task_ task_id
Here
func is the name of the task function.
task_id is a task ID number from 0 to 15
The following example defines the function job0 as a task with a task number of 0.
void job0 (void) _task_ 0 {
while (1) {
counter0 ++; / * increment counter * /
}
}
Note: All tasks must be implemented through loops and never return

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?