Silly question about a process


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Silly question about a process
# 8  
Old 10-26-2007
Quote:
Originally Posted by Legend986
Am I right?
Almost, when you are running a user program your threads may still be kernel threads, as the kernel will do the scheduling and decide when to switch between them.

A user thread is implemented in library outside of the kernel, the kernel still thinks the process is a single threaded one, so the library itself has to do the context switching gymnastics.

But in a user program which uses kernel threads, the kernel knows that the user process contains a number of threads and will do the appropriate scheduling between them.

Note that in order to use an SMP machine (multi CPU etc) efficiently you need kernel threads. If not, then the kernel only thinks your process has one thread and hence all that processes scheduling will occur on one CPU even if the other CPU is idle. With kernel threads, the kernel can run different slices of different threads on different CPUs.
# 9  
Old 10-27-2007
Code:
1. Kernel threads, implemented by the kernel, synchronisation is performed by the kernel.

Does the word ' implementation ' means the library ?
I don't really understand what does it mean here.

Or is the scheduling that is taken care by the kernel ?

Could you please explain that ?

( I have been waiting / expecting these kind of threads in the forum ! Smilie )
# 10  
Old 10-27-2007
I guess so... Threads, as I know, can be implemented either in the user space by the user using some libraries or in the kernel by the kernel using some other libraries (I have a doubt with "some other libraries" though)... For example, as porter actually told me once, if one is using pthreads, they need not have to bother what is happening... Anyways, even I'll wait for an answer but I got something that might actually add to this discussion:

Kernel-level implementation examples

* Light Weight Kernel Threads in various BSDs
* M:N threading (in BSDs)
* Native POSIX Thread Library for Linux, an implementation of the POSIX Threads (pthreads) standard
* Apple Multiprocessing Services version 2.0 and later, uses the built-in nanokernel in Mac OS 8.6 and later which was modified to support it.

User-level implementation examples

* GNU Portable Threads
* FSU Pthreads
* Apple Inc.'s Thread Manager
* REALbasic (includes an API for cooperative threading)
* Netscape Portable Runtime (includes a user-space fibers implementation)

# 11  
Old 10-27-2007
Quote:
Originally Posted by matrixmadhan
Does the word ' implementation ' means the library ?
It means the code that performs the functions, it implements the functions.

Quote:
Originally Posted by matrixmadhan
Or is the scheduling that is taken care by the kernel ?
Yes.

Kernel Threads - the code that implements these runs in the kernel, only the kernel has the ability to do the synchronisation (eg see SMP etc).

User theads - the user process does the synchronisation because the kernel knows nothing about them, there is nobody else.

For instance "Xavier Leroy's LinuxThreads" uses Linux's "clone()" call to make a kernel task that shares the same memory as the current process, so the library provides the API, but the actual thread is a fully fledged kernel task, the kernel does the scheduling and synchronisation.

GNU's portable threads on the other hand uses signals, setjmp/longjmp, contexts or other sleight of hand in order to create a new stack and execution environment in the same process, as the kernel knows nothing about these, all the scheduling and thread switch has to be done by similar sleight of hand setjmp/longjmp, etc.

So which mechanism can take advantage of multiple CPUs and put different threads on different CPUs?

Last edited by porter; 10-27-2007 at 04:13 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Might be silly question

Hi Team, In case if i want to delete one of my posting thread.. can i delete that? Just asking to know.. (5 Replies)
Discussion started by: darling
5 Replies

2. Shell Programming and Scripting

A silly question

FILENAME is a variable. Is there really any difference between "$FILENAME.sh" and "$FILENAME".sh ? (5 Replies)
Discussion started by: proactiveaditya
5 Replies

3. Solaris

I have a silly question

Can anyone tell me where is the best place to put my own system related scripts on a solaris server. I usually place my scripts in /usr/sbin/<my_name>, but that is only because my senior sysadmin used to do that. What does the "unix etiquette" say? (8 Replies)
Discussion started by: soliberus
8 Replies

4. UNIX for Dummies Questions & Answers

silly question ..

hi all last week i had appeared for an interview where they asked me as u work on windows & unix tell me what are the advantages of UNIX over windows & vice versa ..i gave 2-3 reasons but when i told that unix is more secure than windows he asked me how ? i was speechless. then i googled about... (6 Replies)
Discussion started by: zedex
6 Replies

5. Solaris

Silly question regarding SSH.

Hi Guys, I have installed SSH package on server as well as clients. I think I need to these steps next. Login as root on the server. 1) ssh-keygen -b 1024 -t rsa -f /etc/ssh_hosts_key.pub -N " " Login to root as the user. 2)ssh_keygen -b 1024 -t rsa Enter the phrase Basically this... (3 Replies)
Discussion started by: nitinkgoud
3 Replies

6. UNIX for Dummies Questions & Answers

Silly question on printing for loop in AWK

Hi, One silly question. I would like to add statement like below and append to a file. I used the below code; however, it does not work. Can anyone please tell me what mistakes I have made? awk ' { for (i=1;i<=563;i++) print i }'>>output.txt Thanks. -Jason (1 Reply)
Discussion started by: ahjiefreak
1 Replies

7. UNIX for Dummies Questions & Answers

silly question

How do I go about finding the number of unique words in a file. (3 Replies)
Discussion started by: EECSDAVE
3 Replies

8. Shell Programming and Scripting

Silly newbie question on special characters!

Hello again Gurus, Can someone please direct me to an online source that specifically explains what characters like mean within if statements? or scripts in general, I have found information about the different letter options you can specify for an if statment, but I get really confused with the... (3 Replies)
Discussion started by: charliemp3
3 Replies

9. Solaris

Silly Cdrom burn question

Probably a silly question but one I dont know the answer to all the same.. I downloaded the following from sun - solaris 9 part 1 of the software sol-9-u7-sparc-v1.zip When I unzip it I get an iso file. How do I burn it to a cdrom and be able to insert it to solaris machine so that it will... (3 Replies)
Discussion started by: frustrated1
3 Replies

10. Solaris

Silly question

Are GNOME or javadsktop supported of the box on Solaris 10 on Ultra (SUNBlade 1500) ? I'could switch desktops to KDE at CDE logon. But when I tried to use the JavaDesktop it simply returns me back to the log on screen of CDE. How do I conigure to the latest GNOME and.or JavaDesktop if... (3 Replies)
Discussion started by: miket
3 Replies
Login or Register to Ask a Question