Re: Checking status of userspace processes
On Thu, Oct 22, 2009 at 11:53 AM, Leonidas . wrote: > On Thu, Oct 22, 2009 at 11:31 AM, Leonidas . wrote: >> On Thu, Oct 22, 2009 at 2:17 AM, Bob Beers wrote: >>> On Wed, Oct 21, 2009 at 3:07 PM, Leonidas . wrote: On Thu, Oct 22, 2009 at 12:26 AM, Leonidas . wrote: > What would be an ideal way to check if a process/thread is running or > sleeping > or it is dead from kernel space? > > Basically, check whether a process is alive, then determine its status. > > -Leo. > E.g. My module wants to do some cleanup after a thread exits after calling pthread_exit(). The only way my module can know about it by looking in to list of processes but this is not a foolproof since the pid can be recycled. -Leo. >>> >>> Hi Leo, >>> >>> I never did this, but I found it on the internets, so it must be ok ... >>> >>> >>> task_t *p; >>> read_lock(&tasklist_lock); >>> for_each_process(p) { >>> if ( strcmp (p->comm, $your-daemon-name) == 0) >>> break; >>> } >>> read_unlock(&tasklist_lock); >>> >>> sounds not a good idea. Smile >>> >>> >>> But, maybe it gives you some ideas? >>> >>> -bob >>> >> >> >> Hi Bob, >> >> Actaully, I was thinking about something on these lines, like you, I >> was not very convinced with >> this though. Can you fwd me the link? >> >> -Leo. >> > > > I guess the problem will be much easier if know a mechanism to uniquely > identify > an user space entity in kernel. I.e. as pids can be recycled, we will > need to know > a set of parameters which describe a process uniquely no matter > whether the process > is alive or dead. I.e. something like pid + name + ?? + ?? > > > -Leo. > Got the link url. Dont worry about that part. -Leo. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Checking status of userspace processes
I think that you can use one of the functions from include/linux/pid.h like this one: struct pid *find_pid_ns(int nr, struct pid_namespace *ns) 292{ 293struct hlist_node *elem; 294struct upid *pnr; 295 296hlist_for_each_entry_rcu(pnr, elem, 297&pid_hash[pid_hashfn(nr, ns)], pid_chain) 298if (pnr->nr == nr && pnr->ns == ns) 299return container_of(pnr, struct pid, 300numbers[ns->level]); 301 302return NULL; 303} 304EXPORT_SYMBOL_GPL(find_pid_ns) And do not forget to lock the list as Bob suggest. -- Regards, Denis
Re: Checking status of userspace processes
On Thu, Oct 22, 2009 at 11:31 AM, Leonidas . wrote: > On Thu, Oct 22, 2009 at 2:17 AM, Bob Beers wrote: >> On Wed, Oct 21, 2009 at 3:07 PM, Leonidas . wrote: >>> On Thu, Oct 22, 2009 at 12:26 AM, Leonidas . wrote: What would be an ideal way to check if a process/thread is running or sleeping or it is dead from kernel space? Basically, check whether a process is alive, then determine its status. -Leo. >>> >>> E.g. My module wants to do some cleanup after a thread exits after calling >>> pthread_exit(). The only way my module can know about it by looking in to >>> list >>> of processes but this is not a foolproof since the pid can be recycled. >>> >>> >>> -Leo. >>> >> >> Hi Leo, >> >> I never did this, but I found it on the internets, so it must be ok ... >> >> >> task_t *p; >> read_lock(&tasklist_lock); >> for_each_process(p) { >> if ( strcmp (p->comm, $your-daemon-name) == 0) >> break; >> } >> read_unlock(&tasklist_lock); >> >> sounds not a good idea. Smile >> >> >> But, maybe it gives you some ideas? >> >> -bob >> > > > Hi Bob, > > Actaully, I was thinking about something on these lines, like you, I > was not very convinced with > this though. Can you fwd me the link? > > -Leo. > I guess the problem will be much easier if know a mechanism to uniquely identify an user space entity in kernel. I.e. as pids can be recycled, we will need to know a set of parameters which describe a process uniquely no matter whether the process is alive or dead. I.e. something like pid + name + ?? + ?? -Leo. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Checking status of userspace processes
On Thu, Oct 22, 2009 at 2:17 AM, Bob Beers wrote: > On Wed, Oct 21, 2009 at 3:07 PM, Leonidas . wrote: >> On Thu, Oct 22, 2009 at 12:26 AM, Leonidas . wrote: >>> What would be an ideal way to check if a process/thread is running or >>> sleeping >>> or it is dead from kernel space? >>> >>> Basically, check whether a process is alive, then determine its status. >>> >>> -Leo. >>> >> >> E.g. My module wants to do some cleanup after a thread exits after calling >> pthread_exit(). The only way my module can know about it by looking in to >> list >> of processes but this is not a foolproof since the pid can be recycled. >> >> >> -Leo. >> > > Hi Leo, > > I never did this, but I found it on the internets, so it must be ok ... > > > task_t *p; > read_lock(&tasklist_lock); > for_each_process(p) { > if ( strcmp (p->comm, $your-daemon-name) == 0) > break; > } > read_unlock(&tasklist_lock); > > sounds not a good idea. Smile > > > But, maybe it gives you some ideas? > > -bob > Hi Bob, Actaully, I was thinking about something on these lines, like you, I was not very convinced with this though. Can you fwd me the link? -Leo. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: 32 bit processors / 64 bit processors
On Wed, 21 Oct 2009 13:13:03 +0530, askb wrote: > On Wed, 2009-10-21 at 11:09 +0530, Siddu wrote: >> >> >> On Wed, Oct 21, 2009 at 8:32 AM, Rick Brown >> wrote: >> Hi, >> >> Firstly, I'm trying to understand what exactly characterizes a >> procesor or an operating system as 32bit / 64 bit. I've read >> that it >> means the "native word size" of a machine. But what exactly is >> that? >> Register size? Address bus size? Anything else? >> >> >> When they say its 32/64 bit machine its the capability of the system >> or processor to process so many bits at once ! > > Additionally, the virtual memory address is 64 bit. Also the main > difference is with sizeof(long int) and sizeof(void *) on both archs. > >> >> >> >> Secondly, I'm trying to understand what exactly does a >> sizeof(int) >> depend on when we say it is "platform specific". Is it >> dependent of >> compiler being 32bit / 64 bit? Or the OS being 32bit / 64 bit? >> Or the >> processor being 32 / 64 bit? >> >> its dependent on processor being 32/64 bit >> >> >> Lastly, How are "sizes" of compiler / OS / processor inter >> related? >> Here is my understanding. A 32 bit processor can only be >> running a 32 >> bit OS. >> >> No ... 32 bit OS can run anything <= 32 bit >> >> A 64 bit processor may run a 32 or a 64 bit OS. >> >> yes thats right ! >> >> >> A 32 bit >> compiler genrates code only to be run on a 32 bit OS; ditto >> for 64 >> bit. >> >> Not sure about this let others have their say ! >> >> Is this right? > > It is possible to use the -m32 and -m64 flags with gcc for generating > 32/64 bit compatible code. > > > > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecar...@nl.linux.org > Please read the FAQ at http://kernelnewbies.org/FAQ Hi, >> means the "native word size" of a machine. But what exactly is >> that? >> Register size? Address bus size? Anything else? To make it more generic, native word size is the bit width of the ALU in the CPU IMO. Some MCUs will use microcode to "reflect" the ALU into several registers, even as much as 4096. These are referred to as "Accumulator mapped" CPUs/MCUs. So the registers (typically) will be the same size as the ALU, but the register bit width can be larger in some CPUs and vice-versa. Also note that you could have an 8 bit CPU with 32 bit address bus - for example. Or conversely, a 32 bit CPU might only need 64K (16 bits) or more to hold its actual program code. In conclusion the address bus is really irrelevant to the native word size. HTH B rgds Kris -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Ontario Linux Fest this Saturday in Toronto.
Just at the time I'm landing in Toronto. ;( You guys have fun there! Regards, Simon Yan On Oct 22, 2009, at 12:51 AM, Joel Fernandes wrote: Hi Robert, Unfortunately I will not be able to attend it, are videos going to be made available later? Is there anyway we can catch it live? Good luck with the session. Thanks, Joel On Wed, Oct 21, 2009 at 9:05 AM, Robert P. J. Day > wrote: http://onlinux.ca/ and this would be me: http://onlinux.ca/node/78 see u there. rday -- = = = = Robert P. J. Day Waterloo, Ontario, CANADA Linux Consulting, Training and Kernel Pedantry. Web page: http://crashcourse.ca Twitter: http://twitter.com/rpjday = = = = -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ -- 益牙 http://www.google.com/profiles/simonyanix -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Checking status of userspace processes
On Wed, Oct 21, 2009 at 3:07 PM, Leonidas . wrote: > On Thu, Oct 22, 2009 at 12:26 AM, Leonidas . wrote: >> What would be an ideal way to check if a process/thread is running or >> sleeping >> or it is dead from kernel space? >> >> Basically, check whether a process is alive, then determine its status. >> >> -Leo. >> > > E.g. My module wants to do some cleanup after a thread exits after calling > pthread_exit(). The only way my module can know about it by looking in to list > of processes but this is not a foolproof since the pid can be recycled. > > > -Leo. > Hi Leo, I never did this, but I found it on the internets, so it must be ok ... task_t *p; read_lock(&tasklist_lock); for_each_process(p) { if ( strcmp (p->comm, $your-daemon-name) == 0) break; } read_unlock(&tasklist_lock); sounds not a good idea. Smile But, maybe it gives you some ideas? -bob -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Checking status of userspace processes
On Thu, Oct 22, 2009 at 12:26 AM, Leonidas . wrote: > What would be an ideal way to check if a process/thread is running or sleeping > or it is dead from kernel space? > > Basically, check whether a process is alive, then determine its status. > > -Leo. > E.g. My module wants to do some cleanup after a thread exits after calling pthread_exit(). The only way my module can know about it by looking in to list of processes but this is not a foolproof since the pid can be recycled. -Leo. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Checking status of userspace processes
What would be an ideal way to check if a process/thread is running or sleeping or it is dead from kernel space? Basically, check whether a process is alive, then determine its status. -Leo. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Ontario Linux Fest this Saturday in Toronto.
Hi Robert, Unfortunately I will not be able to attend it, are videos going to be made available later? Is there anyway we can catch it live? Good luck with the session. Thanks, Joel On Wed, Oct 21, 2009 at 9:05 AM, Robert P. J. Day wrote: > > http://onlinux.ca/ > > and this would be me: > > http://onlinux.ca/node/78 > > see u there. > > rday > -- > > > Robert P. J. Day Waterloo, Ontario, CANADA > > Linux Consulting, Training and Kernel Pedantry. > > Web page: http://crashcourse.ca > Twitter: http://twitter.com/rpjday > > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecar...@nl.linux.org > Please read the FAQ at http://kernelnewbies.org/FAQ > >
Re: Ontario Linux Fest this Saturday in Toronto.
On Wed, Oct 21, 2009 at 11:05 PM, Robert P. J. Day wrote: > > http://onlinux.ca/ > > and this would be me: > > http://onlinux.ca/node/78 > > see u there. Wish you had a great presentation and receive positive responses from the audience! -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Ontario Linux Fest this Saturday in Toronto.
http://onlinux.ca/ and this would be me: http://onlinux.ca/node/78 see u there. rday -- Robert P. J. Day Waterloo, Ontario, CANADA Linux Consulting, Training and Kernel Pedantry. Web page: http://crashcourse.ca Twitter: http://twitter.com/rpjday -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: Are there any places to put bug report for specific kernel versions?
hi peter, El Wed, Oct 21, 2009 at 08:18:07PM +0800 Peter Chen ha dit: > I find the 2.6.28 kernel has the system hangs problem at ARMv6 SoC > platform after hundreds of reboot test, such problems do not happen at > earlier kernel version. So I wonder if there is kernel bug report for > specific kernel version? afaik http://bugzilla.kernel.org/ is the appropiate place to file your bug report -- Matthias Kaehlcke Embedded Linux Engineer Barcelona Nationalism is an infantile disease. It is the measles of mankind (Albert Einstein) .''`. using free software / Debian GNU/Linux | http://debian.org : :' : `. `'` gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `- -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Are there any places to put bug report for specific kernel versions?
Hi, all: I find the 2.6.28 kernel has the system hangs problem at ARMv6 SoC platform after hundreds of reboot test, such problems do not happen at earlier kernel version. So I wonder if there is kernel bug report for specific kernel version? the 2 error msgs like below: usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver Unable to handle kernel paging request at virtual address e59a3004 pgd = c3898000 [e59a3004] *pgd= Internal error: Oops: 805 [#1] PREEMPT Modules linked in: g_usbdrv(+) ehci_hcd usbcore snd_soc_cb_modac_ts snd_soc_modac snd_soc_sirfsoc_i2s snd_soc_ts_stream_mode snd_soc_sirfsoc snd_soc_core snd_pcm snd_timer snd soundcore snd_page_alloc sirfsoc_bl sirfsoc_fb cfbcopyarea cfbimgblt cfbfillrect CPU: 0Not tainted (2.6.28-default #1) PC is at run_timer_softirq+0x164/0x238 LR is at run_timer_softirq+0x20/0x238 pc : []lr : []psr: 8193 sp : c3949db8 ip : c3949db8 fp : c3949de4 r10: c0309330 r9 : 000a r8 : e353 r7 : c3948000 r6 : ba6d r5 : c3949db8 r4 : c033b040 r3 : 00200200 r2 : e59a3000 r1 : c3949db8 r0 : c00a9860 Flags: Nzcv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user Control: 00c5387d Table: c3898008 DAC: 0015 Process udevd (pid: 44, stack limit = 0xc3948260) Stack: (0xc3949db8 to 0xc394a000) 9da0: e59a3000 c3a1c8ac 9dc0: 0081 0004 0102 c033ae80 c3948000 c033ae80 c3949e1c c3949de8 9de0: c00a42d8 c00a984c c033d638 c3948000 c030a024 c3948000 c0340378 9e00: 0001 c3948000 c3a630c0 c3949e34 c3949e20 c00a4720 c00a4274 9e20: c0340378 c3949e54 c3949e38 c008605c c00a4690 f902 9e40: 0001 0001 c3949ee4 c3949e58 c0086a64 c008600c 0005 c3a196c0 9e60: c3407d38 c3a196d4 c3a5d1d8 c3948000 c393ede0 c3a630c0 c3a01ae0 9e80: c3a630c0 c3949ee4 c3492450 c3949ea0 c34924e8 c009cd60 a013 9ea0: 0004 c3a630f4 c3a01b14 c3a630c4 c3a630c0 c3949ee4 0001 9ec0: c3a52de0 01200011 c3948000 c3a78640 c3a78640 c3949f3c c3949ee8 9ee0: c009db68 c009cbb0 c393e6a8 4001e000 c3949f3c c3a78728 9f00: c3949fb0 bedf0428 c3a5d1d8 c3a01ae0 c3949fb0 01200011 9f20: bedf0428 c3949f8c c3949f40 c009df20 c009cfdc 9f40: 4001cc28 c3a01b14 1000 4001e000 c0087004 9f60: c3948000 4001cc28 002c 002c 0078 c0087004 c3948000 40141000 9f80: c3949fa4 c3949f90 c0089e1c c009dec0 4001cc28 c3949fa8 9fa0: c0086e80 c0089df4 4001cc28 c3949fb0 01200011 9fc0: 4001cc28 002c 002c 0078 bedf0428 0001f3a4 40141000 bedf0484 9fe0: 4001d080 bedf0428 4001cbe0 400b3b00 6010 01200011 204b4e49 77736e61 Backtrace: [] (run_timer_softirq+0x0/0x238) from [] (__do_softirq+0x70/0x108) [] (__do_softirq+0x0/0x108) from [] (irq_exit+0x9c/0xa4) [] (irq_exit+0x0/0xa4) from [] (__exception_text_start+0x5c/0x8c) r5:c0340378 r4: [] (__exception_text_start+0x0/0x8c) from [] (__irq_svc+0x44/0xc8) Exception stack(0xc3949e58 to 0xc3949ea0) 9e40: 0005 c3a196c0 9e60: c3407d38 c3a196d4 c3a5d1d8 c3948000 c393ede0 c3a630c0 c3a01ae0 9e80: c3a630c0 c3949ee4 c3492450 c3949ea0 c34924e8 c009cd60 a013 r7:0001 r6:0001 r5:f902 r4: [] (dup_mm+0x0/0x3f0) from [] (copy_process+0xb98/0xde0) [] (copy_process+0x0/0xde0) from [] (do_fork+0x6c/0x310) [] (do_fork+0x0/0x310) from [] (sys_clone+0x34/0x3c) [] (sys_clone+0x0/0x3c) from [] (ret_fast_syscall+0x0/0x2c) Code: e5906010 e5812000 e5803000 e59f30c0 (e5821004) Kernel panic - not syncing: Fatal exception in interrupt Message 2: Unable to handle kernel paging request at virtual address e59a3004 pgd = c388 [e59a3004] *pgd= Internal error: Oops: 805 [#1] PREEMPT Modules linked in: sirfsoc_gps rtc1_sirfsoc sirfsoc_wdt sirfsoc_uspserial g_serial g_usbdrv ehci_hcd usbcore snd_soc_cb_modac_ts snd_soc_modac snd_soc_sirfsoc_i2s snd_soc_ts_stream_mode snd_soc_sirfsoc snd_soc_core snd_pcm snd_timer snd soundcore snd_page_alloc sirfsoc_bl sirfsoc_fb cfbcopyarea cfbimgblt cfbfillrect CPU: 0Not tainted (2.6.28-default #1) PC is at run_timer_softirq+0x164/0x238 LR is at run_timer_softirq+0x20/0x238 pc : []lr : []psr: 8193 sp : c3943ad8 ip : c3943ad8 fp : c3943b04 r10: c0309330 r9 : 000a r8 : e353 r7 : c3942000 r6 : ba6d r5 : c3943ad8 r4 : c033b040 r3 : 00200200 r2 : e59a3000 r1 : c3943ad8 r0 : c00a9860 Flags: Nzcv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user Control: 00c5387d Table: c3880008 DAC: 0015 Process init (pid: 842, stack limit = 0xc3942260) Stack: (0xc3943ad8 to 0xc3944000) 3ac0:
Re: How to print Superblock(ext2) data
Hello Mahesh, On Wed, Oct 21, 2009 at 1:24 PM, mahesh sobale wrote: > HI, > > I am new to kernelnewbies. I am trying to print meta data in kernel > space for superblock. > for that i have to fire ioctl and write char device driver(This part i > know), > > But i don't know how create loop device and mount ext2 file system on > that and then print > superblock info. > > You can create loop devices first create a file either using dd which would act like a loop device second find the available loop device by losetup -f then following this command you can create a loop device losetup create a file system on the loop device mke2fs mount -t ext2 using tune2fs or even debugfs u can get superblock info tune2fs -l or debugfs followed by stats Can anybody help on this. > > Thanx. > Mahesh. > > -- Regards: Vineet Agarwal
Re: How to print Superblock(ext2) data
On Wed, Oct 21, 2009 at 1:24 PM, mahesh sobale wrote: > HI, > > I am new to kernelnewbies. I am trying to print meta data in kernel > space for superblock. > for that i have to fire ioctl and write char device driver(This part i > know), > > But i don't know how create loop device and mount ext2 file system on > that and then print > superblock info. You can just do "dumpe2fs -h device_name" > > Can anybody help on this. > > Thanx. > Mahesh. > > -- Thanks - Manish == [$\*.^ -- I miss being one of them == -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: How to print Superblock(ext2) data
Hi Mahesh, On Wed, Oct 21, 2009 at 1:24 PM, mahesh sobale wrote: > HI, > > I am new to kernelnewbies. I am trying to print meta data in kernel > space for superblock. > for that i have to fire ioctl and write char device driver(This part i > know), > how about using debugfs. root#debugfs /dev/myvg/lv0 Try help to see all the possible commands. > But i don't know how create loop device and mount ext2 file system on > that and then print > superblock info. > dd if=/dev/zero of=./ext2image1 seek=50 count=0 &> /dev/null #Setup loopback devices modprobe loop losetup -d /dev/loop0 losetup /dev/loop0 ./ext2image1 mke2fs /dev/lopp0 mount /dev/loop0 /mnt This will mount the loop device on /mnt You can use debugfs on loop device. umount /mnt debugfs /dev/loop0 > Can anybody help on this. > > Thanx. > Mahesh. > > HTH, -- Regards, Sandeep. “To learn is to change. Education is a process that changes the learner.” -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
How to print Superblock(ext2) data
HI, I am new to kernelnewbies. I am trying to print meta data in kernel space for superblock. for that i have to fire ioctl and write char device driver(This part i know), But i don't know how create loop device and mount ext2 file system on that and then print superblock info. Can anybody help on this. Thanx. Mahesh.
Re: 32 bit processors / 64 bit processors
On Wed, 2009-10-21 at 11:09 +0530, Siddu wrote: > > > On Wed, Oct 21, 2009 at 8:32 AM, Rick Brown > wrote: > Hi, > > Firstly, I'm trying to understand what exactly characterizes a > procesor or an operating system as 32bit / 64 bit. I've read > that it > means the "native word size" of a machine. But what exactly is > that? > Register size? Address bus size? Anything else? > > > When they say its 32/64 bit machine its the capability of the system > or processor to process so many bits at once ! Additionally, the virtual memory address is 64 bit. Also the main difference is with sizeof(long int) and sizeof(void *) on both archs. > > > > Secondly, I'm trying to understand what exactly does a > sizeof(int) > depend on when we say it is "platform specific". Is it > dependent of > compiler being 32bit / 64 bit? Or the OS being 32bit / 64 bit? > Or the > processor being 32 / 64 bit? > > its dependent on processor being 32/64 bit > > > Lastly, How are "sizes" of compiler / OS / processor inter > related? > Here is my understanding. A 32 bit processor can only be > running a 32 > bit OS. > > No ... 32 bit OS can run anything <= 32 bit > > A 64 bit processor may run a 32 or a 64 bit OS. > > yes thats right ! > > > A 32 bit > compiler genrates code only to be run on a 32 bit OS; ditto > for 64 > bit. > > Not sure about this let others have their say ! > > Is this right? It is possible to use the -m32 and -m64 flags with gcc for generating 32/64 bit compatible code. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ
Re: 32 bit processors / 64 bit processors
1. The size of the processor's internal address bus (virtual address space) is what qualifies it as a 32-bit / 64-bit processor. Whether or not the OS changes the processor mode to 64-bit(IA-32e/Long etc) (and thereby has access to the 64-bit virtual address space, extended register set etc) is what qualifies it as a 32-bit / 64-bit OS. AFAIK, no x86 processor truly supports the complete 64-bit address space (yet) - a. The virtual address space is 64 bits, but still limited by the canonical addressing restriction ( no access to the complete 64-bit virtual address space) b. The physical address is not 64 bits (no system uses such a large amount of physical memory, so there's no point providing such a large number of address pins out to the memory controller / DRAM) 2. sizeof(int) would be depend on the compiler (which in turn depends on the OS it is compiling for, which in turn depends on what processor it is running on). (Though personally I haven't seen sizeof(int) being anything other than 4 bytes .. but I've seen sizeof(long int) being 64 bits for x86-64 gcc, and 32 bits for i386 gcc) 3. If you consider x86 architecture, since they're always backward compatible, any code you generated for an earlier processor should theoretically run on a newer processor (when the processor in a specific mode). Hence, a 64-bit processor can run a 32-bit OS / 64-bit OS. A 64-bit OS can run programs compiled for 64-bit /32-bit mode(by reverting to a 32-bit mode on the fly). This might not apply to other architectures though. C On Tue, Oct 20, 2009 at 11:02 PM, 益牙 wrote: > > On Oct 21, 2009, at 1:39 PM, Siddu wrote: > >> >> >> On Wed, Oct 21, 2009 at 8:32 AM, Rick Brown >> wrote: >> Hi, >> >> Firstly, I'm trying to understand what exactly characterizes a >> procesor or an operating system as 32bit / 64 bit. I've read that it >> means the "native word size" of a machine. But what exactly is that? >> Register size? Address bus size? Anything else? >> >> >> When they say its 32/64 bit machine its the capability of the system or >> processor to process so many bits at once ! > > I had an understanding of this being how many bits you have to address your > RAM. > >> >> >> Secondly, I'm trying to understand what exactly does a sizeof(int) >> depend on when we say it is "platform specific". Is it dependent of >> compiler being 32bit / 64 bit? Or the OS being 32bit / 64 bit? Or the >> processor being 32 / 64 bit? >> >> its dependent on processor being 32/64 bit > > Just did a comparison test but it tells me otherwise. But I'm not sure if > the test case if correct, can someone improve it? > On a 64bit CentOS: > [r...@yyan ~]# more test.c > #include > > int main () > { > printf ("%d\n", sizeof(int)); > return 0; > } > [r...@yyan ~]# gcc test.c > [r...@yyan ~]# ./a.out > 4 > [r...@yyan ~]# uname -a > Linux yyan.pmlab.com 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 > x86_64 x86_64 x86_64 GNU/Linux > [r...@yyan ~]# > > On my Leopard: (Hopefully it's a 32bit OS as it shows) > simonmac:coding yansimon$ cat test.c > #include > > int main () > { > printf ("%d\n", sizeof(int)); > return 0; > } > simonmac:coding yansimon$ gcc test.c > simonmac:coding yansimon$ ./a.out > 4 > simonmac:coding yansimon$ uname -a > Darwin simonmac.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 > PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 > simonmac:coding yansimon$ > > >> >> Lastly, How are "sizes" of compiler / OS / processor inter related? >> Here is my understanding. A 32 bit processor can only be running a 32 >> bit OS. >> >> No ... 32 bit OS can run anything <= 32 bit >> >> A 64 bit processor may run a 32 or a 64 bit OS. >> >> yes thats right ! >> >> A 32 bit >> compiler genrates code only to be run on a 32 bit OS; ditto for 64 >> bit. >> >> Not sure about this let others have their say ! >> Is this right? >> >> >> Please correct me if i am wrong ! >> TIA, >> >> Rick >> >> -- >> To unsubscribe from this list: send an email with >> "unsubscribe kernelnewbies" to ecar...@nl.linux.org >> Please read the FAQ at http://kernelnewbies.org/FAQ >> >> >> >> >> -- >> Regards, >> ~Sid~ >> I have never met a man so ignorant that i couldn't learn something from >> him >> > > -- > 益牙 > > http://www.google.com/profiles/simonyanix > > -- > To unsubscribe from this list: send the line "unsubscribe linux-newbie" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.linux-learn.org/faqs > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ