上一页 1 2 3 4 5 6 7 8 ··· 13 下一页
摘要: 从现在开始来分析和负载平衡有关的策略。/* * This function gets called by the timer code, with HZ frequency. * We call it with interrupts disabled. * * It also gets called by the fork code, when changing the parent's * ti... 阅读全文
posted @ 2012-04-29 17:21 linyvxiang 阅读(850) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1408 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdio.h> 4 int mat[1001][1001]={0}; 5 int main() 6 { 7 int m,n; 8 9 int i,j;10 for(i=0;i<=1000;i++) mat[0][i]=1;11 for(i=0;i<=1000;i++) mat[i][0]=1;12 for(i=1;i<=1000;... 阅读全文
posted @ 2012-04-26 19:44 linyvxiang 阅读(230) 评论(0) 推荐(0) 编辑
摘要: ULK中讲的,感觉这个想法很巧妙,也不翻译了,保留原意吧。Read-copy update (RCU) is yet another synchronization technique designed to protect datastructures that are mostly accessed for reading by several CPUs. RCU allows many re... 阅读全文
posted @ 2012-04-22 15:35 linyvxiang 阅读(380) 评论(0) 推荐(0) 编辑
摘要: 前面主要分析的是新建一个进程时,内核在调度方面进行的处理。现在来看当时钟中断时会发生的动作。当时钟中断发生时,顺着中断处理程序调用路线,会调用到scheduler_tick()/* * This function gets called by the timer code, with HZ frequency. * We call it with interrupts disabled. * *... 阅读全文
posted @ 2012-04-21 22:21 linyvxiang 阅读(1286) 评论(0) 推荐(0) 编辑
摘要: C语言结构体对齐也是老生常谈的话题了。基本上是面试题的必考题。内容虽然很基础,但一不小心就会弄错。写出一个struct,然后sizeof,你会不会经常对结果感到奇怪?sizeof的结果往往都比你声明的变量总长度要大,这是怎么回事呢? 开始学的时候,也被此类问题困扰很久。其实相关的文章很多,感觉说清楚的不多。结构体到底怎样对齐? 有人给对齐原则做过总结,具体在哪里看到现在已记不起来,这里引用一下前人的经验(在没有#pragma pack宏的情况下): 原则1、数据成员对齐规则:结构(struct或联合union)的数据成员,第一个数据成员放在offset为0的地方,以后每个数据成员存储的起始位置 阅读全文
posted @ 2012-04-18 09:55 linyvxiang 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 先把我们最初开始的函数写上,前面写的太长,不再看下原始代码可能回不去了。/* * Share the fairness runtime between parent and child, thus the * total amount of pressure for CPU stays equal - new tasks * get a chance to run but frequent for... 阅读全文
posted @ 2012-04-16 21:39 linyvxiang 阅读(804) 评论(0) 推荐(0) 编辑
摘要: 上次主要分析了进入wake_up_new_tak()后,调用effective_prio来获得调度器所关心的优先级,现在接着往下走。在执行完effective_prio后,会执行以下语句: p->prio = effective_prio(p); if (!p->sched_class->task_new || !current->se.on_rq) { activate_task(rq, p,... 阅读全文
posted @ 2012-04-15 19:22 linyvxiang 阅读(480) 评论(0) 推荐(0) 编辑
摘要: 结束小米的酱油笔试后,师父给我发短信说受打击了,一个学姐说考外难度巨大,需要提前好好准备。我不以为然。师父说那学姐去年考了360,中科院,结果没考上。我给师父扯,说有几个理由可以不去鸟那学姐的话。1)如果一个女生能保研,基本就会保了,不会再去努力争取更好的。2)在西电,如果一个女生不能保研,说明她平时没认真学习,光玩了。(虽然保研并不是什么光彩的事,但是光玩也是不对的)3)如果初试分够了(360已... 阅读全文
posted @ 2012-04-15 11:17 linyvxiang 阅读(137) 评论(0) 推荐(0) 编辑
摘要: http://pat.zju.edu.cn/contests/pat-practise/1027继续无聊。数制转换一定不要忘了0. 1 #include <stdio.h> 2 #include <stack> 3 using namespace std; 4 void trans(int dig) 5 { 6 if(dig == 0){ 7 printf("00"); 8 return; 9 }10 stack<char> S;11 while(dig){12 int temp=dig%13;13 ... 阅读全文
posted @ 2012-04-15 10:49 linyvxiang 阅读(200) 评论(0) 推荐(0) 编辑
摘要: http://pat.zju.edu.cn/contests/pat-practise/1025超级无聊的模拟题。 1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 using namespace std; 5 int N; 6 int K; 7 struct Student{ 8 char name[14]; 9 int score;10 int loc_number;11 int loc_rank;12 }stu[30000];13 bool cmp(struct St 阅读全文
posted @ 2012-04-15 10:12 linyvxiang 阅读(357) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 13 下一页