jfo planet

Hope is the best gift that tomorrow gives.

  • 首页
  • 分类
  • 归档
  • 标签
  • 搜索
close

L4:thread creation

发表于 2008-10-22   |   分类于 l4ka::pistachio/iguana
创建线程create_thread()创建进程可参考l4ka-pistachio-cb2d287364bc/user/apps/l4test/threads.cc:create_thread (bool new_space, int cpu){       static L4_Fpage_t kip_area, utcb_area;    static L4_Word_t utcb_base;    static bool initialized = false;    static void kip;    if (! initialized)    {        kip = L4_KernelInterface ();    ...
阅读全文 »

L4:map pages from sigma0

发表于 2008-10-22   |   分类于 l4ka::pistachio/iguana
客户端请求在root task中通常会先将地址空间的所有页面从sigma0中分配出来,这样以后创建的thread运行时,若没有指定pager,仍然可以正常运行。具体的请求页面操作如下所示:        // ** pin all code and data of the root task by requesting the pages from sigma0        for (const char addr = &elf_start; addr < &elf_end; addr += pagesize)        {                if (!request_pag ...
阅读全文 »

优先级反转

发表于 2008-10-22   |   分类于 Linux
优先级反转一般性描述     优先级反转发生在一个高优先级的任务被迫等待一段不确定时 间,图1中3 个任务分别为task1、task2和task3,其优先级由高到低。 从图1可知,当task3占有由信号量(semaphore)保护的某种共享资源而 进入临界区执行时,task1就绪,由于系统的抢占式调度策略,出现 task1抢占task3执行。task1执行一段时间后也进入临界区,但此时 task3仍占有此临界资源的信号量,task1被阻塞,等待task3释放此信 号量。在经过这么一段时间后,task2已处于就绪状态,于是系统调 度task2执行。如果task3在task2的执行期间一直没有能够被调度执行 的话,那task1和task3将一直等到task2执行完后才能执行,task1更要 等到task3释放它所占有的信号量才能执行;如果这段时间超出task1 的最后期限,task1的调度出现了问题,此时轻则任务被长时间 阻塞,重则造成系统崩溃。 优先级反转原因可归纳为:高优先级的任务task1 由于要等待被低优先级任务 task3占有的临界资源 ...
阅读全文 »

【zz】一种变进制数及其应用(全排列之Hash实现)

发表于 2008-10-18   |   分类于 c/c++/algorithm
my任意一个排列a3a1a5a2a4,与变进制数31524对应,以变进制数31524为索引(数组下标),即可查找到对应的这个排列。hash(a3a1a5a2a4) = 31524反之,以数组下标也可以查找到对应的排列myhttp://bbs.chinaunix.net/archiver/?tid-1283459.html我们经常使用的数的进制为“常数进制”,即始终逢p进1。例如,p进制数K可表示为K = a0p^0 + a1p^1 + a2p^2 + … + anp^n (其中0 <= ai <= p-1),它可以表示任何一个自然数。对于这种常数进制表示法,以及各种进制之间的转换大家应该是很熟悉的了,但大家可能很少听说变进制数。这里我要介绍一种特殊的变进制数,它能够被用来实现 全排列的Hash函数,并且该Hash函数能够实现完美的防碰撞和空间利用(不会发生碰撞,且所有空间被完全使用,不多不少)。这种全排列Hash函数也 被称为全排列数化技术。下面,我们就来看看这种变进制数。我们考查这样一种变进制数:第1位逢2进1,第2位逢3进1,……,第n位逢n+1进1。它的表示形式为K ...
阅读全文 »

inotify 监控文件系统的活动

发表于 2008-10-18   |   分类于 Linux
example code#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <sys/types.h>#include <sys/inotify.h>#define EVENT_SIZE ( sizeof (struct inotify_event) )#define BUF_LEN     ( 1024 ( EVENT_SIZE + 16 ) )int main( int argc, char **argv ) { int length, i = 0; int fd; int wd; char buffer[BUF_LEN]; fd = inotify_init(); if ( fd < 0 ) {    perror( "inotify_init" ); } wd = inotify_add_watch( fd, "/ ...
阅读全文 »

【zz】make the other person fell important and do it sincerely

发表于 2008-10-18   |   分类于 Life
http://blog.csdn.net/futurelight/archive/2008/09/27/2985516.aspx  I could not, of course, accept your resignation without some explanation. I took her aside and said,"Paulette, you must understand that I can’t accept your resignation. You mean a great deal to me and to this company, and you are important to the success of this restaurant as I am."I repeated this in front of the entire staff, and I invited her to my home and reiterated my confidence in her with my family present.  &quo ...
阅读全文 »

L4学习收集

发表于 2008-10-17   |   分类于 l4ka::pistachio/iguana
Fiasco/L4 System Call C-Bindings Reference Manualhttp://os.inf.tu-dresden.de/l4env/doc/html/l4sys-l4v2/index.htmliguanahttp://ertos.nicta.com.au/software/kenge/iguana-project/latest/微内核与操作系统的简化http://hi.baidu.com/l4os/blog/item/c2114c82544220bb6c81198b.htmlOperating System Based L4-Like Microkernelhttp://hi.baidu.com/l4os/blog/item/7838405269fb64080df3e3d4.htmlOKL4(Open Kernel Labs)http://wiki.ok-labs.com/PreviousReleasesend
阅读全文 »

【zz】SYSENTER/SYSEXIT

发表于 2008-10-15   |   分类于 Linux
http://www.ibm.com/developerworks/cn/linux/kernel/l-k26ncpu/index.html前言 在 Linux 2.4 内核中,用户态 Ring3 代码请求内核态 Ring0 代码完成某些功能是通过系统调用完成的,而系统调用的是通过软中断指令(int 0x80)实现的。在 x86 保护模式中,处理 INT 中断指令时,CPU 首先从中断描述表 IDT 取出对应的门描述符,判断门描述符的种类,然后检查门描述符的级别 DPL 和 INT 指令调用者的级别 CPL,当 CPL<=DPL 也就是说 INT 调用者级别高于描述符指定级别时,才能成功调用,最后再根据描述符的内容,进行压栈、跳转、权限级别提升。内核代码执行完毕之后,调用 IRET 指令返回,IRET 指令恢复用户栈,并跳转会低级别的代码。其实,在发生系统调用,由 Ring3 进入 Ring0 的这个过程浪费了不少的 CPU 周期,例如,系统调用必然需要由 Ring3 进入 Ring0(由内核调用 INT 指令的方式除外,这多半属于 Hacker 的内核模块所为),权限提升之前 ...
阅读全文 »

glibc中的vfork

发表于 2008-10-11   |   分类于 Linux
vfork:子进程共享父进程的地址空间,对应Linux内核的task struct中的mm struct指针指向同一个mm。在main()函数中调用vfork()时,会把返回地址IP push到堆栈,当子进程返回后,调用任何函数(例如execve),该地址将被覆盖;然而子进程结束,父进程接着运行时表现正常,这说明返回地址在vfork函数中被保存过,父进程在vfork返回前会恢复该返回地址,从而继续正常运行!以下glibc中vfork()的代码说明了这一点:glibc-2.7/sysdeps/unix/i386/vfork.SENTRY(vfork)jmp vforkglibc-2.7/sysdeps/unix/sysv/linux/i386/vfork.SENTRY (vfork)#ifdef __NR_vfork/ Pop the return PC value into ECX. /popl    %ecx/ Stuff the syscall number in EAX and enter into the kernel. /movl&# ...
阅读全文 »

【zz】debian基本系统构建(build Linux system from scratch based on deb packages)

发表于 2008-10-06   |   分类于 Linux App
my1.mkdir -p /opt/root_filesystem/var/cache/apt/archive/partial2.从/var/lib/dpkg/status文件中获取essential,required,important软件包列表3.将所有软件包以及它们所依赖包拷贝到/opt/root_filesystem/var/cache/apt/archive/4.将所有essential,required包用 dpkg -x pkg.deb /opt/root_filesystem/ 解压5.root@jfo-laptop:/# chroot /opt/root_filesystem/ /bin/bash root@jfo-laptop:/# export LC_ALL=Croot@jfo-laptop:/# touch /var/lib/dpkg/{status,available,diversions}6.开始用dpkg安装essential,required包 对所有essential,required包运行 dpkg –force-depends –unpack p ...
阅读全文 »
1…333435…61
jfo

jfo

605 日志
38 分类
4 标签
RSS
GitHub 微博
友情链接
  • 收藏夹
  • 网络剪贴板
  • 爱逛吧
© 2007 - 2018 jfo
由 Hexo 强力驱动
主题 - NexT.Pisces