04 02 Threads and Concurrency Part 2 — Transcript
Full transcript
- 0:08[Music]
- 0:21okay so next would be
- 0:24the multi-core programming
- 0:26okay so for application programmers
- 0:29there are five areas where a multi-core
- 0:32chips
- 0:33present new challenges
- 0:36okay
- 0:37so
- 0:38these are identifying the tasks
- 0:40okay
- 0:41balance
- 0:43you've got data splitting
- 0:46data dependency testing and debugging so
- 0:49let's start with dividing activities or
- 0:51identifying tasks
- 0:53so this means examining application to
- 0:55find activities that can be performed
- 0:57concurrently
- 0:59okay
- 1:00when you say balance finding tasks to
- 1:02run concurrently
- 1:04that provide equal value example don't
- 1:07waste a tread on a trivial tasks
- 1:10all right
- 1:11so next would be data splitting
- 1:14so to prevent the threads from
- 1:16interfering with one another so we have
- 1:18to perform data splitting
- 1:22next is
- 1:24data dependency okay so when you say
- 1:27data dependency if one task is dependent
- 1:30upon the result of another
- 1:33then the task needs to be synchronized
- 1:35to assure
- 1:36access in proper
- 1:38order okay and last would be testing and
- 1:42debugging so inherently more difficult
- 1:44in parallel processing a situation
- 1:47as the race conditions that we mentioned
- 1:49on the processes
- 1:51become much more complex and difficult
- 1:53to identify
- 1:55okay
- 1:56now in a multi-core programming so we
- 1:59will be
- 2:01encountering terms of parallelism and
- 2:02concurrency
- 2:04okay now what's the difference between
- 2:05these two so by definition when you say
- 2:08parallelism it implies a system can
- 2:10perform more than one task
- 2:11simultaneously
- 2:13okay
- 2:14whereas concurrency
- 2:17supports more than one task making
- 2:19progress so single processor you've got
- 2:22the core dual core multi-core octa-core
- 2:25okay you've got the scheduler provided
- 2:27concurrency
- 2:30all right
- 2:32okay
- 2:33so
- 2:35we mentioned earlier concurrency and
- 2:37parallelism
- 2:39okay
- 2:40so a recent trend in computer
- 2:42architecture is to produce tips with
- 2:45multiple cores okay you've got dual
- 2:48cores
- 2:49quad core you've got octa-core all right
- 2:52so
- 2:54a multi-threaded application running on
- 2:56a traditional single core chip
- 2:58would have to be interleaved the threads
- 3:01okay so as shown here so this is a
- 3:04concurrent execution on a single core
- 3:06system
- 3:08okay
- 3:09now on a multi-core chip however
- 3:12the threads could be spread across
- 3:14available
- 3:15course so this is an example of a dual
- 3:18core here
- 3:19okay
- 3:20and the threads are spread across
- 3:24this available course here so t1 or
- 3:26thread one thread two thread three and
- 3:28thread four and so on so they are
- 3:30distributed
- 3:31among the available cores
- 3:34okay so allowing through parallel
- 3:36processing
- 3:38okay so for operating systems multi-core
- 3:41chips require new skeleton learning
- 3:43algorithms so to make better use of the
- 3:46multiple cores
- 3:48available
- 3:49so as multi trading becomes more
- 3:51pervasive
- 3:53and more important so thousands instead
- 3:56of tens of threads okay cpus have been
- 3:59developed to support more simultaneous
- 4:01threads
- 4:02per core in hardware so that means
- 4:05with multi-core
- 4:06okay so the performance is of course
- 4:09faster than a single core
- 4:12okay if you have a single core in the
- 4:15dual core
- 4:16okay so
- 4:18compared so of course
- 4:20you've got several tasks distributed in
- 4:22a single cpu whereas in here the threads
- 4:25are distributed on multiple cores
- 4:28okay so that's faster of course
- 4:31all right
- 4:32so next would be
- 4:35the types of parallelism
- 4:37so in theory
- 4:39there are two two different ways
- 4:41to
- 4:43parallelize the workload okay so these
- 4:47are the data parallelism and the task
- 4:49parallelism
- 4:51okay so when you say data parallelism so
- 4:54this divides the group up amongst
- 4:56multiple cores or threads
- 4:58and performs the same task for each
- 5:01subset of the data so for example
- 5:03dividing a large image into pieces and
- 5:06performing the same digital image
- 5:08processing on each piece
- 5:10on a different core
- 5:12all right so that is data parallelism
- 5:16now when you say task parallelism
- 5:18so dividing the task
- 5:20to be performed among different cores
- 5:22and perform them simultaneously so in
- 5:25practice
- 5:26no program is ever divided up solely by
- 5:29one or other of this
- 5:31but instead
- 5:33some sort of hybrid combination
- 5:37okay
- 5:40okay so next would be
- 5:44showing the data and task parallelism so
- 5:46what's the difference between these two
- 5:48as mentioned earlier
- 5:49when you say data parallelism so
- 5:52distribute subsets of the same data
- 5:54across multiple cores
- 5:57same operations on it
- 5:59all right so when you say task
- 6:01parallelism
- 6:02distributing threads across course okay
- 6:06each thread performing a unique
- 6:09operation
- 6:11all right
- 6:14okay so next would be
- 6:17the amdahl's law okay so what is this
- 6:20amdahl's law so it identifies
- 6:22performance gains from adding additional
- 6:24cores on application that has both
- 6:26serial and parallel components
- 6:28so s is for serial portion and n is the
- 6:32number or the processing course here
- 6:35so this would compute this or this would
- 6:37improve improve or speed up okay the
- 6:40performance
- 6:41that is if application is 75 parallel
- 6:44and 25 serial so moving from one to two
- 6:48course results in a speed up of 1.6
- 6:50times actually it's not doubled all
- 6:52right so it's not that if we are using a
- 6:55single core
- 6:56okay and we are using a dual core on the
- 6:59other end so we cannot conclude that the
- 7:03process has been doubled
- 7:05okay
- 7:06so to compute that speed up you'll have
- 7:08this formula here
- 7:10okay
- 7:12so and
- 7:13as mentioned here now
- 7:15if the application is 75 parallel and 25
- 7:18serial so moving from a single core to a
- 7:22dual core results to the speed of 1.6
- 7:25times only
- 7:27all right so as n approaches infinity so
- 7:30speed up approaches one over s here
- 7:33okay
- 7:34now the serial portion of the
- 7:35application has this proportionate
- 7:38effect on the performance gained by
- 7:40adding additional course
- 7:42okay
- 7:45so this is what i stated on the
- 7:48amdahl's law presented
- 7:50in the previous slide
- 7:52okay
- 7:53so if you'll have here
- 7:55this
- 7:56on this x-axis you've got the number of
- 8:00processing cores and on the y-axis
- 8:03you've got to speed up
- 8:04so if you are using a dual core so this
- 8:07is something like 1.6 right based on the
- 8:09computation
- 8:10okay so if you are using a quad core of
- 8:13course it's less than
- 8:15times four
- 8:16okay
- 8:23all right
- 8:24so next would be the user
- 8:27and the kernel trends
- 8:28okay so there are two types of threads
- 8:31to be managed in a modern system and
- 8:33these are of course the user threads and
- 8:35the kernel threads all right so i say
- 8:37user threads management done by user
- 8:40level
- 8:41okay
- 8:42and kernel threads is supported by the
- 8:44kernel okay
- 8:46so for the user threads
- 8:48so this includes the posix threads okay
- 8:51which are used in linux okay
- 8:54you also have this windows threads on
- 8:57windows of course and java threads
- 9:01now for the kernel threads
- 9:03so
- 9:04virtually all general purpose operating
- 9:06system including windows
- 9:09linux mac os ios and android this are
- 9:12all under kernel threads
- 9:17all right
- 9:21okay
- 9:22so
- 9:23user threads are supported above the
- 9:25kernel
- 9:26okay so this is your kernel threads this
- 9:28is your user threads so user threads are
- 9:31supported above the kernel without
- 9:33kernel support okay
- 9:35so these are threads
- 9:37that the application programmers would
- 9:40put into their programs
- 9:42and when you say kernel threads
- 9:44kernel threads are supported within the
- 9:47kernel of the os itself so all modern
- 9:51oss support kernel level threads
- 9:54allowing the kernel to perform multiple
- 9:55simultaneous tasks
- 9:58and or
- 9:59to service multiple kernel system calls
- 10:02simultaneously okay
- 10:04now in a specific implementation
- 10:07the user thread must be mapped to kernel
- 10:10threads so using
- 10:12one of the following strategies here
- 10:16okay so there are three multi-threading
- 10:20models and that includes
- 10:23many to one one to one and many too many
- 10:27okay so what's the difference between
- 10:28these three here okay
- 10:30so let's start with minutes one
- 10:33okay so in the minute to one model many
- 10:36user level threads all right
- 10:39are mapped into a single kernel thread
- 10:41here
- 10:42okay so thread management is handled by
- 10:45the thread library in the user space
- 10:48okay
- 10:50which is very efficient
- 10:52so however
- 10:54if a blocking system calls made
- 10:59then the entire process blocks even if
- 11:02the other user threads would otherwise
- 11:05be able to continue
- 11:08okay
- 11:08so one chart blocking causes also black
- 11:13now because a single thread or a single
- 11:16kernel thread can operate only on a
- 11:18single cpu
- 11:19the many-to-one model does not allow
- 11:21individual processes
- 11:23to be split across multiple cpus
- 11:29so
- 11:29green threads
- 11:32for solaris
- 11:33okay
- 11:35and
- 11:36gnu portable threads implemented
- 11:39the many to one model in the past but
- 11:42few system continued to do so today
- 11:45all right so the next one would be
- 11:49one to one okay now with one to one
- 11:52model it creates a separate kernel
- 11:53thread to handle its user thread here so
- 11:56there is
- 11:58a corresponding user threads okay so for
- 12:01every kernel threads here and vice versa
- 12:03okay so one to one model overcomes the
- 12:06problems listed above
- 12:08involving blocking system calls and
- 12:10splitting of processes across multiple
- 12:12cpus
- 12:13so however the overhead of managing
- 12:16one-to-one model is more significant
- 12:19involving the overhead
- 12:22and okay the the slowing down of the
- 12:25system
- 12:26so most implementations of this model
- 12:29place a limit on how many threads are
- 12:31created
- 12:33okay
- 12:34so these are being implemented on
- 12:37windows and linux
- 12:41okay
- 12:42so next would be
- 12:46the many-to-many model
- 12:48with many-to-many model
- 12:50it multiplexes
- 12:52any number of user threads
- 12:54onto an equal or smaller number of
- 12:58kernel threads so combining the best
- 13:00feature of
- 13:02one to one and many to one models
- 13:05so users have no restrictions on the
- 13:07number of threads created
- 13:09okay
- 13:10so black in kernel system calls do not
- 13:12block the enter process so process can
- 13:14be split into
- 13:16or across multiple processors if you are
- 13:18using multiple processors
- 13:20and individual processes may be
- 13:22allocated variable numbers of kernel
- 13:24threads
- 13:25depending on the number of cpus present
- 13:28and other factors
- 13:32right okay
- 13:35so
- 13:36how about this two level
- 13:38okay how about this two level model so
- 13:41what is this so the two level model
- 13:44is a popular variation
- 13:47of the many to many model
- 13:51okay so which allows either many to many
- 13:54or one-to-one operation
- 13:57okay now this model
- 14:00is being implemented on irix
- 14:03hp ux and the true 64 unix
- 14:06okay
- 14:07as did with solaris prior to solaris 9.
- 14:20[Music]
- 14:28you
About this transcript
This page contains the full transcript of 04 02 Threads and Concurrency Part 2 by Santelmo, generated from the public captions YouTube serves with the video. The transcript has 1,676 words across 358 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.