久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標(biāo)題:
RT_THREAD系統(tǒng)中的位圖算法
[打印本頁(yè)]
作者:
Tiramisu520
時(shí)間:
2017-5-25 15:57
標(biāo)題:
RT_THREAD系統(tǒng)中的位圖算法
#include<stdio.h>
unsigned char rt_ready_stable[32];//have 8bit per array,all 256bbit
unsigned long rt_thread_priority_group;//
unsigned char highest_priority_thread;
//unsigned char thread_mask;
//unsigned char thread_high_mask;
/*
biggest priority is 8,and the map is belowing
rt_lowest_bitmap[index]
the biggest priority is 32,and the map is belowing
[31......0] 32bit in all
index=priority_group&0xff,......
rt_lowest_bitmap[index]
the biggest priority is 256,and the map is belowing
[31.........0] 32bit in all
[7...0] 8bit in all
index1=rt_lowest_bitmap[index]
result=rt_lowest_bitmap[index1]
*/
const unsigned char rt_lowest_bitmap[] =
{
/* 00 */ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 10 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 20 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 30 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 40 */ 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 50 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 60 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 70 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 80 */ 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* 90 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* A0 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* B0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* C0 */ 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* D0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* E0 */ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
/* F0 */ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
};
/**
* @function get the lowest bit of one byte
*/
unsigned char GetLowBit(unsigned char byte)
{
unsigned char i;
unsigned char c;
c=0;//init the number
for(i=0;i<8;i++)
{
if(byte&0x01)
return c;
c=c+1;
byte=byte>>1;
}
return 0;
}
/**
*@functon print all the lowest bit arrange 0 to 255
*/
void PrintTheMap(void)
{
unsigned short i;
for(i=0;i<256;i++)
{
printf("%d,",GetLowBit(i));
if((i+1)%16==0)
printf("\n");
}
}
/**
* @function create one thread
@param num is the priority
*/
void CreateOneThread(unsigned char num)
{
unsigned char current_priority;
unsigned long priority_byte;
unsigned char priority_bit;
unsigned char priority_number;
current_priority=num;
priority_number=num>>3;//the integer of 8
priority_byte=1<<priority_number; //sure the bit of 32bit number
priority_bit=1<<(current_priority&0x07);//the rest of 8
#if 1
rt_ready_stable[priority_number] |=priority_bit;
#endif
rt_thread_priority_group |=priority_byte;
}
/**
* @functon find the highest_priority;
*/
unsigned char Find_Highest_priority()
{
#if RT_HTREAD_PRIORITY_MAX==8
highest_priority_thread=rt_lowest_bitmap[rt_thread_priority_group];
return highest_priority_thread;
#endif
unsigned char number;
if(rt_thread_priority_group&0xff)
{
number=rt_lowest_bitmap[(rt_thread_priority_group)&0xff];
}
else if(rt_thread_priority_group&0xff00)
{
number=rt_lowest_bitmap[(rt_thread_priority_group>>8)&0xff]+8;
}
else if(rt_thread_priority_group&0xff0000)
{
number=rt_lowest_bitmap[(rt_thread_priority_group>>16)&0xff]+16;
}
else
{
number=rt_lowest_bitmap[(rt_thread_priority_group>>24)&0xff]+24;
}
highest_priority_thread=(number<<3)+rt_lowest_bitmap[rt_ready_stable[number]];
return highest_priority_thread;
}
歡迎光臨 (http://m.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
成人国产精品一区二区
|
日韩有码av
|
亚洲精品久久久久久久久
|
av不卡在线
|
欧美成人精品一区二区三区在线看
|
亚洲精品一区二区三区精华液
|
日韩免费一区二区
|
亚洲成人精品在线
|
日本国产在线观看
|
九九热精品在线
|
亚洲欧美国产毛片在线
|
中文字幕理伦片免费看
|
日本视频免费观看
|
a级片在线观看
|
夜夜操av
|
日韩一区二区三区四区
|
久草免费在线视频
|
亚洲一区二区三区在线视频
|
成人在线观看视频网站
|
av天天干
|
五月天黄色网
|
国产黄色精品视频
|
日韩在线欧美
|
免费黄色小说网站
|
日韩国产欧美
|
四虎影视最新地址
|
久久久精品在线观看
|
欧美性色网
|
视频爱爱免费视频爱爱太爽
|
三上悠亚一区
|
四虎成人精品
|
午夜激情网
|
亚洲网站在线
|
日韩精品视频在线免费观看
|
a在线免费观看
|
亚洲一区二区国产精品
|
男人天堂av网
|
99久久精品国产一区二区三区
|
日本乱子伦
|
91午夜理伦私人影院
|
国产黄色三级
|