YouTube2Text

04 01 Threads and Concurrency Part 1a — Transcript

by Santelmo · 1,336 words · 291 segments · language en · Watch on YouTube

Full transcript

  1. 0:01[Music]
  2. 0:08[Music]
  3. 0:20hello there
  4. 0:22this video lecture covers
  5. 0:25threads
  6. 0:26and concurrency
  7. 0:28okay so this topic is next to processes
  8. 0:32okay so the last video that we had
  9. 0:35all right
  10. 0:36so let's get started
  11. 0:38so bear with me this discussion is a
  12. 0:40little bit too technical okay and we
  13. 0:43will be dealing with a lot of terms here
  14. 0:46okay so for the outline of the video so
  15. 0:50we will be dealing with an overview
  16. 0:52of a thread okay
  17. 0:55so also included are the multi-core
  18. 0:58programming
  19. 0:59the multi-threading models the thread
  20. 1:02libraries
  21. 1:03implicit threading
  22. 1:05the threading issues and some operating
  23. 1:08system examples when it comes to threads
  24. 1:12okay so at the end of this discussion so
  25. 1:16we should be able to identify the basic
  26. 1:17components of a thread
  27. 1:20and contrast threads and processes so
  28. 1:24last time we we talked about process and
  29. 1:27when she processed this is a programming
  30. 1:29execution okay so how about threads so
  31. 1:32threads
  32. 1:33before okay
  33. 1:35during the process discussion we defined
  34. 1:37it as
  35. 1:38a sub process
  36. 1:40all right
  37. 1:42next would be
  38. 1:43describe the benefits and challenges of
  39. 1:46designing a multi-threaded applications
  40. 1:49illustrate different approaches to
  41. 1:52implicit trading including tread pools
  42. 1:55fork join
  43. 1:56and grand central dispatch
  44. 2:00so describe how windows and linux
  45. 2:02operating systems
  46. 2:04represent threads
  47. 2:05and design a multi-threaded application
  48. 2:08using the pthreads java and the windows
  49. 2:12trading apis
  50. 2:24[Music]
  51. 2:32so let's start with the definition of
  52. 2:35thread so what is the thread okay
  53. 2:37so thread basically is a basic unit of
  54. 2:40cpu utilization
  55. 2:42consisting of a program counter
  56. 2:45a stack
  57. 2:46and a set of registers
  58. 2:49and a thread id
  59. 2:51okay
  60. 2:52so what what are the motivations for
  61. 2:54having a thread
  62. 2:56okay so most modern applications are
  63. 2:59multi-threaded
  64. 3:01okay so threads run within application
  65. 3:05so that means
  66. 3:07thread is
  67. 3:09a sub process
  68. 3:11okay so multiple tasks
  69. 3:13with the application can be implemented
  70. 3:15by separate threads so update display
  71. 3:20fetch data spell checking so our example
  72. 3:23is of course in microsoft word okay so
  73. 3:26we're in when we run the application we
  74. 3:28have a lot of threads okay so that was
  75. 3:31initialized when we open it
  76. 3:34okay and then answer a network request
  77. 3:37is also
  78. 3:38a good example
  79. 3:40okay so process creation is a heavy
  80. 3:44weight
  81. 3:45while trend creation is a light rate so
  82. 3:47that's why we have the motivation for
  83. 3:50creating a thread okay so it can simply
  84. 3:53simplify the code and increase
  85. 3:55efficiency
  86. 3:57kernels are generally multi-threaded
  87. 4:00okay
  88. 4:01so basically threads are very useful in
  89. 4:04modern programming
  90. 4:05so whenever a process has multiple tasks
  91. 4:08to perform independently
  92. 4:10of the others
  93. 4:11okay so a good uh multi-threaded
  94. 4:15application for programming is of course
  95. 4:17java
  96. 4:18okay
  97. 4:19so this is particularly true when one of
  98. 4:22the tasks may block
  99. 4:25and it is desired to allow the other
  100. 4:27tasks to proceed without blocking so for
  101. 4:30example
  102. 4:32so in a word processor
  103. 4:34a background thread may check spelling
  104. 4:36and grammar
  105. 4:38while a foreground thread
  106. 4:40process or processes user inputs like
  107. 4:42keystrokes
  108. 4:44okay
  109. 4:45so while yet a third thread loads images
  110. 4:49from the hard drive and the fourth does
  111. 4:51periodic automatic backups
  112. 4:54of the file being edited okay
  113. 4:56so let me open here
  114. 5:00a
  115. 5:01[Music]
  116. 5:03task manager so that we'll be able to
  117. 5:05see the threads there okay
  118. 5:19all right
  119. 5:20so we have here our task manager okay so
  120. 5:24of course we have here the process is
  121. 5:26running
  122. 5:27okay
  123. 5:28and basically you'll have the background
  124. 5:30processes and
  125. 5:32some foreground processes running here
  126. 5:34okay or the windows processes
  127. 5:37now so these are the resources allocated
  128. 5:40to each of the process
  129. 5:41okay
  130. 5:42now looking at the performance so let's
  131. 5:45examine the cpu utilization here so the
  132. 5:48cpu utilization is 36 percent so i'm
  133. 5:51using 2.7
  134. 5:54okay plus plus gigahertz
  135. 5:56of the cpu frequency here
  136. 5:59okay
  137. 6:00now
  138. 6:01if you will observe here with a 38
  139. 6:04utilization okay and the speed of 2.74
  140. 6:07though the cpu is basically 2.3
  141. 6:09gigahertz so you'll you'll have that um
  142. 6:12it exceeded the the frequency okay now
  143. 6:15what i want you to pay attention here is
  144. 6:18the number of processes here okay
  145. 6:21now for the number of processes so
  146. 6:23currently we are running 155 processes
  147. 6:27and there are about
  148. 6:291683 threads
  149. 6:31okay so if you are running virtual
  150. 6:33machines like virtualbox so you would
  151. 6:35also see here if you have enabled the
  152. 6:38virtualization on the
  153. 6:41cmos
  154. 6:42all right
  155. 6:43now
  156. 6:44so currently i'm running 153 processors
  157. 6:47and with that processes there are about
  158. 6:49a thousand six hundred plus threads okay
  159. 6:53so let me open ms word here okay
  160. 6:57so windward
  161. 7:01let me open it and what i want you to
  162. 7:03pay attention with is the number of
  163. 7:05threads there okay
  164. 7:06so
  165. 7:08examine or observe what will happen
  166. 7:10when i open ms word
  167. 7:15all right so there is a sudden increase
  168. 7:18of the number of threads
  169. 7:20okay
  170. 7:21so we just opened microsoft word there
  171. 7:23all right
  172. 7:24and microsoft word has a lot of threads
  173. 7:26associated with it so as mentioned
  174. 7:28earlier so this includes like spelling
  175. 7:31check
  176. 7:32okay
  177. 7:33uh grammar check
  178. 7:35what else uh the keystrokes the number
  179. 7:37of characters and so on
  180. 7:39okay
  181. 7:41so let me close this
  182. 7:44all right so
  183. 7:46next
  184. 7:52okay so we have
  185. 7:54what we call a single threaded or a
  186. 7:56multi-threaded processes
  187. 7:59so traditionally
  188. 8:01we've got the heavyweight processes
  189. 8:03it has a single thread of control so
  190. 8:06there is one program counter
  191. 8:08and a sequence or one sequence of
  192. 8:10instructions that can carry it out at
  193. 8:13any given time
  194. 8:15okay now as shown in this diagram here
  195. 8:18okay so we've got a multi-threaded
  196. 8:21applications
  197. 8:22okay and it has multiple threads with a
  198. 8:25single process
  199. 8:27okay
  200. 8:28so you've got multiple threads here okay
  201. 8:30so this string
  202. 8:32like
  203. 8:34diagram or symbol here represents a
  204. 8:36thread okay
  205. 8:38now we have here
  206. 8:40a multi-threaded process if you will
  207. 8:42observe we have three
  208. 8:43threads running with a single process
  209. 8:46and each of the thread has their own
  210. 8:48registers stack and program counter
  211. 8:51but the code the data and the files are
  212. 8:54shared among the threads
  213. 8:57all right
  214. 9:03all right
  215. 9:04so next would be the multi-threaded
  216. 9:06server architecture okay so what do we
  217. 9:09have in the multi-threaded architecture
  218. 9:12so another example of
  219. 9:14a thread okay so like what we've
  220. 9:16mentioned earlier ms word example so
  221. 9:19another example is the web server
  222. 9:21so multiple threads allows or allow for
  223. 9:24multiple requests to be satisfied
  224. 9:26simultaneously okay without having to
  225. 9:29service the request sequentially
  226. 9:31or to fork
  227. 9:33separate processes for every incoming
  228. 9:35request
  229. 9:36okay
  230. 9:37so a dame one would listen at a port
  231. 9:41fork of a child for every incoming
  232. 9:43request
  233. 9:44to process
  234. 9:46and then
  235. 9:47go back to the listening port
  236. 9:50all right
  237. 9:51so
  238. 9:52that is shown on this diagram here
  239. 9:56okay
  240. 9:57so next would be
  241. 10:00what are the benefits of a trend
  242. 10:03okay so basically there are four major
  243. 10:05categories of benefits
  244. 10:07to multi-threading so these are
  245. 10:09responsiveness
  246. 10:10resource sharing economy and scalability
  247. 10:14okay
  248. 10:15now on the responsiveness so one thread
  249. 10:18may provide rapid response while other
  250. 10:21threads are blocked or slowed down doing
  251. 10:24intensive calculations
  252. 10:27all right
  253. 10:28so next would be resource sharing
  254. 10:31so by default
  255. 10:32threads share common code data and other
  256. 10:35resources as shown in the model earlier
  257. 10:37okay so which allows multiple tasks
  258. 10:41to be performed simultaneously in a
  259. 10:43single address space
  260. 10:45that's resource sharing
  261. 10:47okay
  262. 10:49third is economy
  263. 10:51so creating and managing threads and
  264. 10:53contact switches between them
  265. 10:55is much faster than performing
  266. 10:58same tasks for processes
  267. 11:01all right so that's economy
  268. 11:03and the last one would be scalability so
  269. 11:05an example of this is the utilization of
  270. 11:08a multi-processor architectures
  271. 11:10okay so a single threaded process can
  272. 11:12only run one or can only run on one cpu
  273. 11:16no matter how many
  274. 11:18may be available
  275. 11:20whereas the execution of a
  276. 11:21multi-threaded application
  277. 11:23may be split amongst available
  278. 11:25processors
  279. 11:27okay so note that a single threaded
  280. 11:29process can still benefit from a
  281. 11:31multi-processor architectures
  282. 11:34when there are multiple processes
  283. 11:36contending for the cpu
  284. 11:38example when the load average is above
  285. 11:41some certain threshold
  286. 11:43okay so
  287. 11:45basically the use of threads are
  288. 11:47beneficial
  289. 11:49all right
  290. 11:54[Music]
  291. 12:06you

About this transcript

This page contains the full transcript of 04 01 Threads and Concurrency Part 1a by Santelmo, generated from the public captions YouTube serves with the video. The transcript has 1,336 words across 291 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.