Quiz# 1: Threads

1. Which context switch is faster?

Between threads.
Between processes.

2. Switching between user-level threads is faster than kernel-level threads because

User-level threads are small.
Switching between user-level threads is independent of the operating system.
Kernel is slow.

3. A process created by using the fork() system call in UNIX

Shares its address space with its parent.
Gets an identical copy of the address space of its parent.

4. Threads share their stack and program counter with other threads within a process.

True
False

5. A thread cannot create any child threads.

True
False

6. A thread cannot read or write any other thread's stack.

True
False

7. I want to fork off 5 threads. What is wrong with the following code?
        Thread *t = new Thread("threadname");
        for(i=0;i<4;i++)
          t->Fork(somefuntion,i);


Threads share their address space; the above does not allow that
Space is allocated for only one thread
Every thread forked off has the same name