Multithreading: Exam Questions

  • Which of the following statements about threads is true? (Wrong answers are subtracted from correct answers.)

    • A thread shares an address space with all other threads in a process.

    • Threads are an operating system’s way of keeping track of all the events that happen while a system is running.

    • A thread’s memory is isolated from all other threads in the system.

    • When a program starts, the process is made up of one initial thread, the main thread

    • Threads are a way of achieving parallel execution within the same address space.

  • What can happen when two threads modify the same integer at the same time (for example using a plain “+” operator in most programming languages)? (One answer.)

    • One of the modifications might be lost.

    • Everything will be ok.

  • Which of the following statements about race conditions is true? (Wrong answers are subtracted from correct answers.)

    • Two or more threads execute a loop, and it is not entirely clear which one finishes first.

    • It is a race condition if two or more threads access the same data at the same time, without providing any protection for potentially overlapping non-atomic operations.

  • What device is usually used to prevent race conditions? (One answer.)

    • A mutex

    • Character device

cluster_python Python Programming: From Absolute Beginner to Advanced Productivity cluster_python_advanced Python: More Language Features cluster_python_advanced_multithreading Multithreading cluster_python_advanced_oo Object Oriented Programming cluster_python_basics Python: The Language Fundamentals python_advanced_multithreading_exam_questions Multithreading: Exam Questions python_advanced_multithreading_mutex Race Conditions, and Mutexes python_advanced_multithreading_exam_questions->python_advanced_multithreading_mutex python_advanced_multithreading_basics Multithreading (Python) python_advanced_multithreading_exam_questions->python_advanced_multithreading_basics python_advanced_multithreading_mutex->python_advanced_multithreading_basics python_advanced_oo_inheritance Inheritance python_advanced_multithreading_basics->python_advanced_oo_inheritance python_advanced_oo_constructor Constructor python_advanced_oo_classes_and_dicts Classes And Dictionaries python_advanced_oo_constructor->python_advanced_oo_classes_and_dicts python_basics_python_0150_datatypes_overview_compound Compound Datatypes python_advanced_oo_classes_and_dicts->python_basics_python_0150_datatypes_overview_compound python_advanced_oo_inheritance->python_advanced_oo_constructor python_advanced_oo_inheritance->python_advanced_oo_classes_and_dicts python_basics_python_0140_variables Variables python_basics_python_0130_syntax_etc Syntax etc. python_basics_python_0140_variables->python_basics_python_0130_syntax_etc python_basics_python_0150_datatypes_overview Datatypes python_basics_python_0150_datatypes_overview->python_basics_python_0140_variables python_basics_python_0110_blahblah Blahblah python_basics_python_0120_helloworld Hello World python_basics_python_0120_helloworld->python_basics_python_0110_blahblah python_basics_python_0130_syntax_etc->python_basics_python_0120_helloworld python_basics_python_0150_datatypes_overview_compound->python_basics_python_0150_datatypes_overview