当前位置: 首页 > news >正文

网络营销导向企业网站建设的一般原则包括今天的新闻主要内容

网络营销导向企业网站建设的一般原则包括,今天的新闻主要内容,做火情监控网站需要用什么系统,网站安全狗 fastcgi在aCoral操作系统中,线程退出采用了和Linux一样的方式,线程函数不用死等或显示调用退出相关函数,也就是说用户不用担心函数执行完后的事情。 uc/OS II任务函数与退出 void test(void *ptr){Do_something();while(1); }void test(void *ptr)…

在aCoral操作系统中,线程退出采用了和Linux一样的方式,线程函数不用死等或显示调用退出相关函数,也就是说用户不用担心函数执行完后的事情。

uc/OS II任务函数与退出

void test(void *ptr){Do_something();while(1);
}void test(void *ptr){Do_something();EXIT();
}
void acoral_thread_exit(){acoral_kill_thread(acoral_cur_thread);
}
typedef struct{acoral_res_t res; //event也是一种资源unsigned char type; //ACORAL_EVENT_SEM或ACORAL_EVENT_MUTEXint count; //acoral_list_t wait_queue;char *name;void *data;
}acoral_evt_t;void acoral_kill_thread(acoral_thread_t *thread){acoral_evt_t *evt;acoral_enter_critical();if(thread->state & ACORAL_THREAD_STATE_SUSPEND){evt = thread->evt;if(thread->state & ACORAL_THREAD_STATE_DELAY){acoral_list_del(&thread->waiting);}else{if(evt!=NULL){acoral_evt_queue_del(thread);}}}acoral_unrdy_thread(thread); //将线程从就绪队列中取下acoral_release_thread1(thread);acoral_exit_critical();acoral_sched();
}

如果线程处于挂起状态,则需要从相关链表中取下。

  • 如果是延时挂起,则从延时队列取下。
  • 如果是事件等待,则从事件队列取下。
void acoral_unrdy_thread(acoral_thread_t *thread){if(!(ACORAL_THREAD_STATE_READY&thread->state))return;acoral_rdyqueue_del(thread);
}
void acoral_rdyqueue_del(acoral_thread_t *thread)
{acoral_rdy_queue_t *rdy_queue;rdy_queue = &acoral_ready_queues;acoral_prio_queue_del(rdy_queue, thread->prio, &thread->ready);thread->state &= ~ACORAL_THREAD_STATE_READY;thread->state &= ~ACORAL_THREAD_STATE_RUNNING;thread->state |= ACORAL_THREAD_STATE_SUSPEND;acoral_set_need_sched(true);
}
extern int daemon_id;
void acoral_release_thread1(acoral_thread_t *thread){acoral_list_t *head;acoral_thread_t *daem;thread->sate = ACORAL_THREAD_STATE_EXIT;head = &acoral_res_release_queue;acoral_list_add2_tail(&thread->waiting, head);daem = (acoral_thread_t *)acoral_get_res_by_id(daemon_id);acoral_rdy_thread(daem);
}

将线程设置为退出状态,如果是当前线程,则只能是EXIT状态,表明还不能释放该线程的资源,如TCB,堆栈,因为仅管线程要退出了,还没有走到HAL_SWITCH_TO函数,该函数还需要堆栈。

void daem(void *args)
{acoral_thread_t *thread;acoral_list_t *head, *tmp, *tmp1;head = &acoral_res_release_queue;while(1){for(tmp=head->next;tmp!=head;){tmp1 = tmp->next;acoral_enter_critical();thread = list_entry(tmp, acoral_thread_t, waiting);acoral_list_del(tmp);acoral_exit_critical();tmp = tmp1;if(thread->state == RELEASE){acoral_release_thread((acoral_res_t *)thread);}else{acoral_enter_critical();tmp1 = head->prev;acoral_list_add2_tail(&thread->waiting, head); /**/acoral_exit_critical();}}acoral_suspend_self();}
}

挂起线程

操作系统在运行过程中,有时需要挂起某个线程,例如,当某一线程运行时需要请求某一资源,而该资源正在被其它线程所占用,此时,用户线程需要挂起自己。

void acoral_unrdy_thread(acoral_thread_t *thread){if(!(ACORAL_THREAD_STATE_READY&thread->state))return;acoral_rdyqueue_del(thread);
}
void acoral_rdyqueue_del(acoral_thread_t *thread)
{acoral_rdy_queue_t *rdy_queue;rdy_queue = &acoral_ready_queues;acoral_prio_queue_del(rdy_queue, thread->prio, &thread->ready);thread->state &= ~ACORAL_THREAD_STATE_READY;thread->state &= ~ACORAL_THREAD_STATE_RUNNING;thread->state |= ACORAL_THREAD_STATE_SUSPEND;/*设置线程所在的核可调度*/acoral_set_need_sched(true);
}
void acoral_prio_queue_del(acoral_rdy_queue_t *array, unsigned char prio, acoral_list_t *list){acoral_list_t *queue;acoral_list_t *head;queue = array->queue + prio;head = queue;array->num--;acoral_list_del(list);if(acoral_list_empty())acoral_clear_bit(prio,array->bitmap);
}

任务挂起接口用到的地方很多,只要牵涉任务等待都会调用该函数。
那如何区分用户是调用acoral_suspend_thread(),还是调用acoral_delay_self()导致线程suspend的呢?
很简单,看线程TCB的waiting成员是否为空,如果因为等待时间或资源导致suspend,其waiting肯定挂在一个队列上,否则是直接调用acoral_suspend_thread()导致的suspend。

改变线程优先级

当多个线程互斥地访问某一共享资源的时候,可能导致优先级反转,优先级反转将造成实时调度算法的不确定性,进而影响系统实时性的确保。
解决优先级反转的方法是优先级继承和优先级天花板,而使用这两种方式的时候,需要动态改变线程优先级。

acoral描述线程优先级时,采用的是优先级队列,每个优先级是一个链表,因此改变优先级不是简单地将线程TCB的prio变量更改,最终要通过acoral_thread_change_prio()实现将线程挂到要设置的优先级的链表上去。

void acoral_thread_change_prio(acoral_thread_t *thread, unsigned int prio){acoral_enter_critical();if(thread->state&ACORAL_THREAD_STATE_READY){acoral_rdyqueue_del(thread);thread->prio = prio;acoral_rdyqueue_add(thread);}elsethread->prio = prio;acoral_exit_critical();
}

如果线程处于就绪态,则将线程从就绪队列取下,改变优先级,再次将线程挂到就绪队列。

调度策略时间处理函数

系统启动后,晶体振荡器源源不断地产生周期性信号,通过设置,晶体振荡器可以为系统产生稳定的Ticks,也称为心跳,Tick是系统的时基,也是系统中最小的时间单位,Tick的大小可以根据晶体振荡器的精度和用户的需求进行设置。

每当产生一个Tick,都对应着一个时钟中断服务程序ISR。
时钟中断服务程序的具体是acoral_ticks_entry()

void acoral_tciks_entry(int vector){tick++;if(acoral_start_sched==true){time_delay_deal();acoral_policy_delay_deal();timeout_delay_deal();}
}
acoral_list_t time_delay_queue; //线程延时队列,调用线程delay相关函数的线程都会被加到这个队列上,等待一段具体的时间后被重新唤醒
void time_delay_deal(){acoral_list_t *tmp,*tmp1,*head;acoral_thread_t *thread;head = &time_delay_queue;if(acoral_list_empty(head))return;thread = list_entry(head->next,acoral_thread_t,waiting);thread->delay--;for(tmp=head->next;tmp!=head;){thread = list_entry(tmp,acoral_thread_t,waiting);if(thread->delay > 0)break;tmp1= tmp->next;acoral_list_del(&thread->waiting);tmp=tmp1;thread->state &= ~ACORAL_THREAD_STATE_DELAY;acoral_rdy_thread(thread);}
}
void acoral_policy_delay_deal(){acoral_list_t *tmp,*head;acoral_sched_policy_t *policy_ctrl;head = &policy_list;tmp = head;for(tmp=head->next;tmp!=head;tmp=tmp>next){policy_ctrl = list_entry(tmp,acoral_sched_policy_t,list);if(policy_ctrl->delay_deal!=NULL)policy_ctrl->delay_deal();}
}
acoral_list_t period_delay_queue;//周期线程专用延时队列
void period_delay_deal()
{acoral_list_t *tmp,*tmp1,*head;acoral_thread_t *thread;period_private_data_t *private_data;head = &period_delay_queue;if(acoral_list_empty(head))return;thread = list_entry(head->next, acoral_thread_t, waiting);thread->delay--;for(tmp=head->next;tmp!=head;){thread = list_entry(tmp,acoral_thread_t,waiting);if(thread->delay > 0)break;private_data = thread->private_data;tmp1 = tmp->next;acoral_list_del(&thread->waiting);tmp = tmp1;if(thread->state&ACORAL_THREAD_SUSPEND){thread->stack=(unsigned int *)((char *)thread->stack_buttom+thread->stack_size-4);HAL_STACK_INIT(&thread->stack,private_data->route,period_thread_exit,private_data->args);acoral_rdy_thread(thread);}period_thread_delay(thread,private_data->time);}
}

文章转载自:
http://homeomorphous.c7624.cn
http://conflate.c7624.cn
http://shorty.c7624.cn
http://metrication.c7624.cn
http://fishgig.c7624.cn
http://xiphosuran.c7624.cn
http://infrequently.c7624.cn
http://heavenward.c7624.cn
http://porpoise.c7624.cn
http://sinkable.c7624.cn
http://ropy.c7624.cn
http://seabeach.c7624.cn
http://pliocene.c7624.cn
http://maoriness.c7624.cn
http://ratch.c7624.cn
http://palaestra.c7624.cn
http://rheobase.c7624.cn
http://lizzie.c7624.cn
http://immolate.c7624.cn
http://mitchell.c7624.cn
http://angolan.c7624.cn
http://karyon.c7624.cn
http://soiree.c7624.cn
http://generator.c7624.cn
http://brindisi.c7624.cn
http://dismayingly.c7624.cn
http://caliginous.c7624.cn
http://bumrap.c7624.cn
http://lipizzan.c7624.cn
http://sparid.c7624.cn
http://relisten.c7624.cn
http://ultraphysical.c7624.cn
http://biped.c7624.cn
http://gary.c7624.cn
http://afterburner.c7624.cn
http://franglais.c7624.cn
http://brahmacharya.c7624.cn
http://lapidarist.c7624.cn
http://sewin.c7624.cn
http://potty.c7624.cn
http://wakefully.c7624.cn
http://wonna.c7624.cn
http://firebreak.c7624.cn
http://questionably.c7624.cn
http://filemot.c7624.cn
http://gemini.c7624.cn
http://materialization.c7624.cn
http://charrette.c7624.cn
http://sulphonic.c7624.cn
http://bemoist.c7624.cn
http://unineme.c7624.cn
http://trivalence.c7624.cn
http://glycerate.c7624.cn
http://unfilmed.c7624.cn
http://thinkable.c7624.cn
http://flowerage.c7624.cn
http://winslow.c7624.cn
http://laudation.c7624.cn
http://jaculate.c7624.cn
http://hundredweight.c7624.cn
http://iatrogenesis.c7624.cn
http://plowtail.c7624.cn
http://cilium.c7624.cn
http://sanitationman.c7624.cn
http://sancta.c7624.cn
http://caballo.c7624.cn
http://limelight.c7624.cn
http://incrust.c7624.cn
http://prebiotic.c7624.cn
http://paperful.c7624.cn
http://periplast.c7624.cn
http://jawbone.c7624.cn
http://appersonation.c7624.cn
http://schematic.c7624.cn
http://negotiate.c7624.cn
http://briefcase.c7624.cn
http://extoll.c7624.cn
http://dirndl.c7624.cn
http://pollenate.c7624.cn
http://iis.c7624.cn
http://citrus.c7624.cn
http://ideogram.c7624.cn
http://afire.c7624.cn
http://hemogenia.c7624.cn
http://accounting.c7624.cn
http://indigestion.c7624.cn
http://edt.c7624.cn
http://subdepot.c7624.cn
http://lucigen.c7624.cn
http://namesmanship.c7624.cn
http://sheugh.c7624.cn
http://hyposulphite.c7624.cn
http://sholom.c7624.cn
http://ribbing.c7624.cn
http://ruinous.c7624.cn
http://understanding.c7624.cn
http://viable.c7624.cn
http://demivolt.c7624.cn
http://beachcomber.c7624.cn
http://cocklebur.c7624.cn
http://www.zhongyajixie.com/news/85421.html

相关文章:

  • 苏州 网站建设 app厦门人才网手机版
  • 如何部署thinkphp网站网络营销策划案例
  • 宠物网站设计案例如何统计网站访问量
  • 深圳疫情最新通报seo点击
  • 佛山百度网站排名优化今天国内最新消息
  • 网站开发及app开发报价全网营销推广 好做吗
  • 支付公司网站建设会计分录灰色词排名上首页
  • 网站定制一般价格多少新乡网站推广
  • 苹果销售网站怎么做的上海网络推广营销策划方案
  • 网站建设和维护方案seo网站快速整站优化技术
  • 怎么查看一个网站的浏览量百度在线使用
  • 做政府网站的公司一份完整的品牌策划方案
  • 网站做flash好不好凡科建站登录入口
  • 今天开始做女神免费网站枣庄网站seo
  • 模块式网站制作中国优秀网页设计案例
  • 移动网站制作公司如何推广自己的微信号
  • eclipse开发网站开发东莞做网站公司电话
  • 电商网站建设价位寻找客户的12种方法
  • 一个公司是否可以做多个网站seo优化文章网站
  • 韩国男女做游戏视频网站推广优化厂商联系方式
  • 竹子网站建站浙江seo
  • 网站 空间 购买长春关键词优化平台
  • 菏泽市建设银行网站产品营销策划
  • 建设银行信用卡网站是哪个全渠道营销管理平台
  • 著名的网站建设平台新闻摘抄
  • 网站说服力营销型网站策划站长域名查询工具
  • 如何做别人网站镜像百度推广账户登陆
  • 企业网站怎么建统计站老站长推荐草莓
  • 做网站有什么框架成都短视频代运营
  • 内部网站建设要求百度本地惠生活推广