Task Management Readiness table and ready lease

Source: Internet
Author: User

Task Readiness Table

The ready state flags for each task are placed in the ready table, with two variables osrdygrp and osrdytbl[] in the Ready table.

In Osrdygrp, tasks are grouped by priority, with 8 tasks as a group. Each of the OSRDYGRP indicates whether there are tasks in each group in the 8-group task that have entered the ready state. When the task enters the ready state, the corresponding bit of the corresponding element in the Ready table osrdytbl[] is also placed.

N assuming that the priority 12 task is in the ready state, 12=1100b, then osrdytbl[1] 4th position 1, and the 1th position of the Osrdygrp 1, the corresponding mathematical expression is:

Osrdygrp |=0x02;

OSRDYTBL[1] |=0x10;

N and the Priority 21 task is ready 21=10 101b, then osrdytbl[2] 5th position 1, and osrdygrp 2nd position 1, the corresponding mathematical expression is:

Osrdygrp |=0x04;

OSRDYTBL[2] |=0x20;

N from the above calculation: if Osrdygrp and osrdybbl[] the nth position 1, it should be the value of OSRDYGRP and osrdybbl[] and 2n phase or. In Uc/os, the 8 values of the 2n n=0-7 are calculated first in the presence array osmaptbl[7], i.e.:

Osmaptbl[0] = = 0x01 (0000 0001)

OSMAPTBL[1] = 0x02 (0000 0010)

......

OSMAPTBL[7] = 0x80 (1000 0000)

N if Prio is the priority of the task, that is, the task's identification number, the task is placed in the ready table, even if the task enters the ready state by:

Osrdygrp |= osmaptbl[prio>>3];

OSRDYTBL[PRIO>>3] |= osmaptbl[prio&0x07];

N Assuming priority is 12--1100b

Osrdygrp |=0x02;

OSRDYTBL[1] |=0x10;

n zeroing the corresponding bits of the corresponding element in the task-ready table osrdytbl[prio>>3], and when all the bits in osrdytbl[prio>>3] are zero, that is, when none of the tasks in the group of the task is in the Ready state, The corresponding bit of the OSRDYGRP is zero.

if ((Osrdytbl[prio>>3] &=

~OSMAPTBL[PRIO&0X07]) = = 0)

Osrdygrp &= ~osmaptbl[prio>>3];

Determine the highest priority based on the readiness table

Two key points:

The priority series is decomposed into high three-bit and low three-bit respectively.

High priority has a small priority number;

Task Management Readiness table and ready lease

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.