A question about Operating System: a) What is the difference between a process a
ID: 662455 • Letter: A
Question
A question about Operating System:
a) What is the difference between a process and a thread? Give examples in terms of well-known operating systems. [10 marks] b) Supply Java classes in which you: (i) create several threads, (ii) set these threads running, and (iii) wait for all threads to complete. Indicate via comments any alternative ways to implement equivalent behavior. [20 marks] c) What type of problem can typically be expected to run faster in a multi-threaded implementation than it would in a single-threaded implementation? Give examples and explain your reasoning. [10 marks] d) Conversely, what type of problem can typically be expected to run more slowly in a multi-threaded implementation than it would single-threaded? Again, give examples and explain your reasoning. [10 marks]Explanation / Answer
a)
Both processes and threads are independent sequences of execution.
The typical difference is that threads (of the same process) run in a shared memory space, while processes run in separate memory spaces.
I'm not sure what "hardware" vs "software" threads might be referring to.
Threads are an operating environment feature, rather than a CPU feature (though the CPU typically has operations that make threads efficient).
Erlang uses the term "process" because it does not expose a shared-memory multiprogramming model.
Calling them "threads" would imply that they have shared memory.
Example:
A JVM runs in a single process and threads in a JVM share the heap belonging to that process. That is why several threads may access the same object. Threads share the heap and have their own stack space. This is how one thread