Question

In: Computer Science

What are the basic steps involved with creating a new thread? Why is it ok for...

  • What are the basic steps involved with creating a new thread?
  • Why is it ok for the OS to disable interrupts, but not application programs?

Solutions

Expert Solution

Basic steps involved in the creating Thread

Basically Thread is a light weight process, java language provides support for multi threading.

Thread contains several states

i)new: When we create a instance of Thread class new thread will be created

ii)Running: The java thread in a running state.

iii)Suspended: A running thread can be suspended when temporarily it's activity,once other thread stops it'll be activated by default.

iv) Blocked: When thread can be blocked waiting for a resource

v) Terminated : A thread can be terminated when it's execution is completed , once the the Thread terminated it can't be resumed.

CreateThread.java

class CreateThread extends Thread

{

public void run()

{

System.out.println("Thread is running);

}

public static void main(String args[])

{

CreateThread c=new CreateThread();

c.start();

}

}

2)

i)The reason why we disable the interrupts is it could lead to a dead lock , if an interrupt handler tries to acquire a lock that the interrupted thread has acquired

ii) To protect against the thread owning the lock getting preempted by a rescheduling interrupt and amount of time the lock remains held being extended to an unaccepted long time.

iii) Generally users aren't allowed to use that kind of instruction only it'll be by kernel process.users only access by some routine offered by Kernel API.If the program has some bug or for some reason needs some resource that will be only avliable when some interrupt arrives it enters on infinite loop and the entire CPU will be held by the process.

iv) After that system even can't be restarted only can be rebooted.


Related Solutions

What is the importance of knowing the steps involved in creating an image? Why can’t the...
What is the importance of knowing the steps involved in creating an image? Why can’t the technologist just place the patient under the collimator light and press the exposure button? How many different types of X-ray machines will you be working with as a student technologist or as a technologist? What should you expect to be similar, and what may be different?
What are the steps involved in creating a vaccine? What are researchers looking for and how...
What are the steps involved in creating a vaccine? What are researchers looking for and how is FDA approval achieved?
What are the four basic steps involved with bringing a corporation into existence?
What are the four basic steps involved with bringing a corporation into existence?
What are the four steps, in order, involved in creating an export strategy? List and explain...
What are the four steps, in order, involved in creating an export strategy? List and explain in detail each step.
Your answer 1. Explain why overhead is less when creating a new thread than the overhead...
Your answer 1. Explain why overhead is less when creating a new thread than the overhead to create a process.     Your answer 2. Discuss the types of parallelism and give examples of cases where each would be appropriate. Your answer 3. Provide an example where a multicore-processor-based system could have neither concurrency nor parallelism. 4. Using Amdahl's Law, calculate the speedup gain for the following situation:     75 percent parallel with (a) eight processing cores and (b) sixteen processing...
What are the common steps involved in conducting a research? Discuss the steps involved.
What are the common steps involved in conducting a research? Discuss the steps involved.
1. Why there needs to be user thread and kernel thread? 2. What are the advantages...
1. Why there needs to be user thread and kernel thread? 2. What are the advantages and disadvantages of writing an operating system in a highlevel language, such as C? 3. What is a critical section problem? Demonstrate that with an example. 4. With an example, show how critical section can led to dead locks. 5. Write two differences between a network OS and a distributed OS. 6. Identify the following environments as hard, firm or soft real time. Give...
Consider the steps involved with performing an intellectual property (IP) audit. Discuss why new products and...
Consider the steps involved with performing an intellectual property (IP) audit. Discuss why new products and software applications need to pass an IP audit before they are launched. Why do you believe investors and venture capitalist insist on an IP audit before they invest?
what are the steps involved in updating a schedule
what are the steps involved in updating a schedule
what are the steps involved in the metastatic cascade?
what are the steps involved in the metastatic cascade?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT