Made with ScholarlyMake flashcards like these from your own notes
Question:What is a traditional process in terms of threading?
Answer:A traditional process has a single thread of control.
Question:What distinguishes multi-threaded applications from traditional processes?
Answer:Multi-threaded applications have multiple threads within a single process.
Question:What is the basic unit of CPU utilization when the operating system supports threads?
Answer:A thread is a basic unit of CPU utilization.
Question:How does the weight of process creation compare to thread creation?
Answer:Process creation is many times heavy weight, while thread creation is light weight.
Question:What are the components of each thread?
Answer:Each thread consists of: 1. Thread ID 2. Program Counter 3. Set of registers 4. Stack.
Question:What do threads share within a process?
Answer:Threads share other components of the process such as code, data, and files.
Question:Provide an example of multi-threading in word processing applications.
Answer:In editing a word document, different threads interpret keystrokes, display images, check spelling and grammar, and perform automatic backups periodically.
Question:Why are many operating system kernels multi-threaded?
Answer:Many operating system kernels are multi-threaded to allow each thread to perform a specific task within the kernel process.
Question:List the advantages of using threads.
Answer:1. Responsiveness: may allow continued execution if part of the process is blocked, which is especially important for user interfaces. 2. Resource Sharing: threads share resources by default, making it easier than processes. 3. Economy: thread switching has lower overhead than context switching, making it cheaper than process creation. 4. Scalability: a single process can take advantage of multiprocessor architectures, enabling concurrent programming and true parallelism.
Question:What does parallelism imply in computing?
Answer:Parallelism implies a system can perform more than one task simultaneously.
Question:What does parallelism involve on a multi-core system?
Answer:Parallelism on a multi-core system involves the ability to execute multiple tasks across different cores.
Question:What is concurrency in computing?
Answer:Concurrency supports more than one task making progress.
Question:How does a single processor/core scheduler provide concurrency?
Answer:A single processor/core scheduler provides concurrency by managing the execution of multiple tasks, allowing them to make progress in overlapping time periods.
Question:Is it possible to have concurrency without parallelism?
Answer:Yes, it is possible to have concurrency without parallelism.
Question:What are some challenges faced in multicore programming?
Answer:1. Dividing activities and identifying tasks that can be performed concurrently. 2. Balancing thread creation overhead with performance gain. 3. Data splitting to prevent interference. 4. Managing data dependency. 5. Enabling synchronization. 6. Testing and debugging, which can be challenging due to race conditions.
Question:What are the two types of parallelism in multicore programming?
Answer:The two types of parallelism in multicore programming are Data parallelism and Task parallelism.
Question:What is data parallelism?
Answer:Data parallelism distributes subsets of the same data across multiple cores, performing the same operation on each subset.
Question:Can you provide an example of data parallelism?
Answer:An example of data parallelism is adding numbers from 1 to N, where N is large. The set is divided into a number of cores, and the same computation is performed on each set.
Question:What is task parallelism?
Answer:Task parallelism involves distributing threads across cores, with each thread performing a unique operation.
Question:Can you give an example of task parallelism?
Answer:An example of task parallelism is the Windows word document example, where different threads perform unique operations on the document.
Question:What is the relationship between multicore systems and programmer challenges?
Answer:Multicore or multiprocessor systems put pressure on programmers due to the increased complexity of managing concurrency, data dependencies, and optimizing performance.
Question:What does Amdahl's Law identify?
Answer:Performance gains from adding additional cores to an application that has both serial and parallel components.
Question:What is the formula for Amdahl's Law in terms of serial portion S and processing cores N?
Answer:The formula for Amdahl's Law is the following figure, where: S is the part of the program that is serial (cannot be parallelized). N is the number of processing cores (or processors).
Question:In the context of Amdahl's Law, if an application is 75% parallel, what is the serial portion?
Answer:If an application is 75% parallel, the serial portion S is 25%, or S=0.25 in the formula.
Question:What is the result of moving from 1 to 2 cores according to Amdahl's Law?
Answer:Moving from 1 to 2 cores results in a speedup of 16 times.
Question:What happens to speedup as N approaches infinity according to Amdahl's Law?
Answer:As N approaches infinity, the speedup approaches 1.
Question:What does Amdahl's Law suggest about adding more processes after a certain number?
Answer:Amdahl's Law suggests that adding more processes after a certain number has no effect on speedup.
Question:What is a criticism of Amdahl's Law?
Answer:Some suggest that the formula does not account for hardware performance, therefore ceases to apply when N is high.
Question:What relationship must exist between kernel and user level threads?
Answer:A relationship must exist between kernel and user level threads, as kernel level threads support the functioning of the kernel.
Question:What must the operating system provide for user-created threads?
Answer:The OS must provide support to schedule and execute user-created threads on the CPU.
Question:How does the OS support threads or processes?
Answer:The OS provides support by assigning kernel threads to a thread or a process.
Question:What does the support provided by the OS depend on?
Answer:The support provided by the OS depends on the multithreading model adopted by the OS.
Question:What are the multithreading models adopted by operating systems?
Answer:The multithreading models include Many to One, One to One, and Many to Many.
Question:Describe the Many to One multithreading model.
Answer:In the Many to One model, all user-level threads created by the process are mapped to a single kernel thread.
Question:Who handles thread management in the Many to One model?
Answer:Thread management is handled by the thread library in user space in the Many to One model.
Question:What is a downside of the Many to One multithreading model?
Answer:If one thread blocks, all threads will block, and multiple threads may not run in parallel on a multicore system.
Question:What is an example of a system that implemented the Many to One model?
Answer:An example of a system that implemented the Many to One model is the Green Threads Library available for Solaris.
Question:What is the One to One model in threading?
Answer:Each user level thread is mapped to a kernel thread. Creating a user level thread creates a kernel thread to manage it.
Question:What are the advantages and disadvantages of the One to One threading model?
Answer:It has more concurrency than Many to One but has maximum overhead. The number of threads per process is sometimes restricted due to overhead.
Question:What are some examples of operating systems that use the One to One threading model?
Answer:Examples include Windows, Linux, and Solaris 9 and later.
Question:What is the Many to Many threading model?
Answer:This model allows many user level threads to be mapped to an equal or smaller number of kernel threads. Users have no restrictions on the number of threads created.
Question:What are the effects of blocking kernel system calls in the Many to Many model?
Answer:Blocking kernel system calls do not block the entire process.
Question:How do processes with threads benefit in the Many to Many model?
Answer:Processes with threads can be split across multiple processors.
Question:How are kernel threads allocated in the Many to Many model?
Answer:Individual processes may be allocated variable numbers of kernel threads depending on the number of CPUs present and other factors.
Question:What is an example of an operating system that uses the Many to Many threading model?
Answer:An example includes Solaris prior to version 9.
Question:What is the Two Level model in threading?
Answer:The Two Level model is a variation of Many to Many, allowing a user thread to be bound to a kernel thread.
Question:How is user level threads management done?
Answer:User level threads management is done by a user level threads library in user space.
Question:How are kernel level threads managed?
Answer:Kernel level threads are managed by the Kernel in kernel space.
Question:What is the support for thread management in general purpose operating systems?
Answer:Virtually all general purpose operating systems have thread support, e.g., Windows, Solaris, Linux, Tru64 UNIX, Mac OS X.
Question:What does a thread library provide to programmers?
Answer:A thread library provides an API for creating and managing threads.
Question:What are the two primary ways of implementing thread libraries?
Answer:1. Library entirely in user space – involves API functions implemented solely within user space with no kernel support. 2. Kernel level library supported by the OS – involves system calls and requires a kernel with thread library support.
Question:What are the three main thread libraries in use today?
Answer:1. POSIX Pthreads 2. Win32 threads 3. Java threads
Question:What is POSIX Pthreads?
Answer:A POSIX standard API for thread creation and synchronization that may be provided as either a user or kernel library.
Question:What is the specification of Pthreads?
Answer:The API specifies the behavior of the thread library, while the implementation is up to the development of the library.
Question:On which operating systems is Pthreads commonly used?
Answer:Pthreads is common in UNIX operating systems including Solaris, Linux, and Mac OS X.
Question:What model does the pthread library implement on Linux?
Answer:The pthread library implements the 1:1 model.
Question:What must you include in your C program to create threads using Pthreads?
Answer:You need to include the pthread.h header file.
Question:What type is used for creating thread IDs in Pthreads?
Answer:The pthread_t data type.
Question:How should thread attributes be created or modified in Pthreads?
Answer:Using the pthread_attr_t data structure.
Question:What function is used to create threads in Pthreads?
Answer:The pthread_create function.
Question:What function must be used to ensure the parent thread outputs the sum after all summing threads have exited?
Answer:The pthread_join function.
Question:How does Linux treat processes and threads?
Answer:Linux treats processes and threads the same, referring to them as tasks.
Question:What system call is used for thread creation in Linux?
Answer:The clone system call.
Question:What are some flags that can be set when using the clone system call?
Answer:1. CLONE_FS 2. CLONE_VM 3. CLONE_SIGHAND 4. CLONE_FILES
Question:What does the CLONE_FS flag do?
Answer:Filesystem information is shared.
Question:What does the CLONE_VM flag do?
Answer:The same memory space is shared.
Question:What does the CLONE_SIGHAND flag do?
Answer:Signal handlers are shared.
Question:What does the CLONE_FILES flag do?
Answer:The set of open files is shared.
Question:What is Implicit Threading?
Answer:Implicit Threading is when the creation and management of threads is done by compilers and runtime libraries rather than programmers.
Question:What are three methods of Implicit Threading explored?
Answer:1. Thread Pools 2. OpenMP 3. Grand Central Dispatch.