Silly question about a process


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Silly question about a process
# 1  
Old 10-21-2007
Silly question about a process

I know its kinda silly but I've seen the texts consider one side - a thread executes and finishes its task but I was wondering what will happen if the process dies when the thread is still under execution... I somehow think that the thread will continue execution but am backing off from the fact that a thread shares the data and code of a process... If the process dies then there shouldn't be any data or code and so logically speaking (if there's logic that is Smilie ) there shouldn't be a thread... I seem to be going round in circles... What happens in reality?

And while reading further, I read about multithreading and that was just fine... But when it came to creating a distinction even between threads - user level threads and kernel level threads... I was somewhat not feeling comfortable... As a matter of analogy, if I think as a webbrowser having threads at the user level, it might be serving the user load a page at the same time loading an image in the background, then how can I think of kernel level threads as?
# 2  
Old 10-22-2007
The POSIX model has threads executing within the context of a process. Then a process starts it automatically has one thread executing, the one that calls main. When exit is called the entire process and all threads contained evaporate.

A kernel thread means that the kernel has integral support for threads, some threading libraries implement threads entirely within user space of a process and can work on a non-threaded kernel.

There are pros and cons of each, but most UNIX operating systems now support threads at the kernel level to the kernel can manage the scheduling. With user-space threads, the process itself must manage the scheduling of threads.
# 3  
Old 10-22-2007
Alright, that clears up some misconceptions that I had... So am I right in assuming that there can never be a situation where we might require the threads of a process after killing a process?
# 4  
Old 10-22-2007
Quote:
Originally Posted by Legend986
So am I right in assuming that there can never be a situation where we might require the threads of a process after killing a process?
Threads aren't really visible outside of a process and are internal implementation details.

If you require a thread after the process containing it has died then you have a design problem.
# 5  
Old 10-26-2007
Oh now I see... So the thread is something that pertains only to the process that it belongs to and no other process can inherit it...

As I keep reading I'm getting some real dumb doubts... I don't understand the difference between User Semaphores and Kernel Semaphores... Do they differ only based on where they are implemented...? In that case, I was wondering if two threads of the same process could be synchorinzed using a kernel semaphore if the threads themselves are implemented by a kernel.. I feel that kernel threads should never need semaphores while if they are being implemented at the user level, they can be synchronized using kernel semaphores...

I'm a little confused now so if there was any mistake, kindly correct me....
# 6  
Old 10-26-2007
There are two type of threads.

1. Kernel threads, implemented by the kernel, synchronisation is performed by the kernel.

2. User threads, the kernel knows nothing about the threads hence no need for kernel semaphores, only user semaphores are needed.

As a programmer, if you use the an API such as pthreads you do not care whether the threads are implemented by the kernel or by a user library.
# 7  
Old 10-26-2007
Ok understood... So to boil it down, when the process is in the user space, only we as the programmer can synchronize them using "semaphores that are implemented in the user space" And because the kernel has no idea about the threads that are going on in the user space, we cannot use kernel semaphores... On the other side, threads implemented at the kernel level can be synchronized using kernel semaphores... Am I right?

Quote:
As a programmer, if you use the an API such as pthreads you do not care whether the threads are implemented by the kernel or by a user library.
Yeah... Now my questions seem outdated I guess... Smilie
 
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