TLS - implementing linux one in fbsd (转)
2009-05-13 03:40:45来源:未知 阅读 ()
Date: Tue, 20 Jun 2006 14:09:48 +0200
From: Divacky Roman
Subject: TLS - implementing linux one in fbsd
To: hackers@freebsd.org
Cc: threads@freebsd.org
Message-ID:
Content-Type: text/plain; charset=us-ascii
Hi
I am student working on SoC project - extending linuxolator, now I am working
on implementing linux TLS in FreeBSD. Here is what I think/know and I like you
to comment on this, thnx. Roman
-------------------------------------------------
Linux and FreeBSD TLS implementation - comparison
Both systems use per-thread setting of where is the tls area stored. This setting is loaded into active threads
GDT and can be accessed via %gs register. This GDT setup is done on every context switch.
Linux uses strict 1:1 threading so every thread is in fact process, so thread creation is done using plain
clone()/fork(). FreeBSD uses M:N (including 1:1) threading. Threads are created via pthread_create() call to
threading library. In kernel there's thr_new() syscall or thread_create() syscall. I didnt find the
connection between threading library and kernel but I assume its using one of the syscalls
For setting up the GDT for the thread Linux uses syscall set_thread_area() (TODO - how exactly? its unclear what
it does). I dont know how FreeBSD does it but I think it might be done via params to the syscalls (TODO - how is
it done?)
Remaining questions:
clone() - 2.6.x glibc fork() implementation uses clone() syscall. is it supposed to create a thread or just a
process? I think its process but why is the binary (ls, date and probably some other) linked to pthread library?
is it just Linux "strangeness"? I dont see a reason for ls to be threaded... does anyone see?
set/get tid - does it relate to TLS at all? I dont think so but you never know. The tid thing is unclear to me.
The clone() syscall is passed CLONE_CHILD_SETTID & CLONE_CHILD_CLEARTID which should be mutually exclusive. I dont
believe much its a mistake.. but the code is clear:
p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL;
p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr: NULL;
kostik belousov pointed out that this is used for futexes, so not interesting for this
Possible mapping from Linux to FreeBSD:
To me it seems that the the set_thread_area() syscall is used in the process of thread creation to set where the
tls is stored. In FreeBSD we use cpu_set_user_tls() for this. So it might be enough to just wrap call to
cpu_set_user_tls() into the syscall.
------------------------------
Message: 2
Date: Wed, 21 Jun 2006 06:58:24 +0800
From: David Xu
Subject: Re: TLS - implementing linux one in fbsd
To: freebsd-threads@freebsd.org
Cc: threads@freebsd.org, Divacky Roman ,
hackers@freebsd.org
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:pkgsrc相关设置.
下一篇:软件包管理工具安装与使用方法
- Freebsd oracle 10g 2009-05-13
- KDE/FreeBSD 测试 QT-4.5.1. 2009-05-13
- 提示:bad kernel: arp : 内网IP地址 is on em0 but got rep 2009-05-13
- OpenBSD 4.5下安装Gnome 2.24成功! 2009-05-13
- OpenBSD 4.5 2009-05-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash