{"id":3279,"date":"2022-10-26T16:06:54","date_gmt":"2022-10-26T10:36:54","guid":{"rendered":"https:\/\/cthecosmos.com\/?p=3279"},"modified":"2022-10-26T16:06:54","modified_gmt":"2022-10-26T10:36:54","slug":"threads","status":"publish","type":"post","link":"https:\/\/cthecosmos.com\/?p=3279","title":{"rendered":"THREADS"},"content":{"rendered":"\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<div class=\"wp-block-group has-white-color has-light-gray-background-color has-text-color has-background is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<p class=\"has-black-color has-light-gray-background-color has-text-color has-background wp-block-paragraph\" style=\"font-size:15px;\">Let&#8217;s talk about Threads<br><br>What is a Thread?<br><br>&#8211; A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.<br><br>-A thread is an active entity as it executes as a part of a process. It goes through various stages in its life cycle. A thread is born\/created, started, runs and dies.<br><br>-A thread has a parent\u2019s process control block (PCB), its own thread control block and stack and common address space.<br><br>-Threads within the process run in shared memory space. Thread switching does not need to interact with the operating system, hence threads have lesser context switching time.<br><br>-Thread is a lightweight process hence, takes fewer resources when compared with a process.<br><br>Threads can be implemented in 2 ways, User level threads and Kernel-level threads. The first one is managed by the user while the second, is managed by the operating system that would acts on the kernel i.e an operating system core.<br><\/p>\n\n\n\n<p class=\"has-black-color has-light-gray-background-color has-text-color has-background wp-block-paragraph\" style=\"font-size:15px;\">Few things before we head onto for a simple thread program:<br><br><strong>Create a thread<\/strong><br>To create a thread, we use pthread_create() function that takes 4 parameters.<br><br>1) <strong>ID<\/strong>: This is of type <strong><em>pthread_t *<\/em><\/strong> . It is simply a pointer to the ID of the thread.<br><br>2) <strong>Attributes<\/strong>: <strong><em>pthread_attr_t *<\/em><\/strong> . This is used to set a few attributes of thread. Such as:<br>           <strong>a. Detach State<\/strong> &#8211; Affects how you reclaim or leave active resources associated with a thread when a thread ends<br>( <em>Default: PTHREAD_CREATE_JOINABLE<\/em>)<br><br>          <strong> b. Scope <\/strong>&#8211; Chooses the scheduling contention scope for the created thread.<br>( <em>Default: PTHREAD_SCOPE_SYSTEM<\/em>)<br><br>         <strong> c. Inherit scheduler<\/strong> \u2013 Affects how the priority of the thread is determined by the system.<br>( <em>Default: PTHREAD_EXPLICIT_SCHED<\/em>)<br><br>        <strong> d. Scheduling policy<\/strong> \u2013 Affects how the threads are scheduled within the system or within the application. This is related to thread priority.<br>( <em>Default: SCHED_OTHER<\/em> )<br><br>        <strong>e. Scheduling priority<\/strong> \u2013 Also called as scheduling parameter for the thread.<br>( <em>Default: 0<\/em>)<br><br>        <strong>f. Guard Size<\/strong> \u2013 Changes the minimum size in bytes of the guard area of the thread\u2019s stack. If this value is set, it will be rounded up to the nearest page size.<br>( <em>Default: a single page<\/em>)<br><br>       <strong>g. Stack address<\/strong> &#8211; Provides an address for the application managed stack.<br>(<em>Default: PTHREAD_STACK_MIN<\/em>)<br><br>      <strong> h. Stack Size<\/strong> \u2013 Affects the number of functions that a thread can call before the thread fails due to insufficient stack space<br>(<em>Default: PTHREAD_STACK_MIN<\/em>)<br><br>       <strong>i. Stack<\/strong> \u2013 Provide both the address and size of an application-managed stack to use for the new thread.<\/p>\n\n\n\n<p class=\"has-black-color has-light-gray-background-color has-text-color has-background wp-block-paragraph\" style=\"font-size:15px;\">3) <strong>Starting routine<\/strong>: It is a<strong><em> void *<\/em><\/strong>. This is the name of the function that the thread starts to execute.<br>4) <strong>Arguments<\/strong>: It is a <strong><em>void *<\/em><\/strong>. This is the argument that the starting routine takes.<br><strong><em>pthread_create(&amp;thread_ID], NULL, Calling_this_function, &amp;the_arg)<\/em><\/strong>;<\/p>\n\n\n\n<p class=\"has-black-color has-light-gray-background-color has-text-color has-background wp-block-paragraph\" style=\"font-size:15px;\">To Wait for a thread: Use <strong>pthread_join()<\/strong>. The parameters required are:<br><br><strong>Thread ID<\/strong>: It is of type <strong><em>pthread_t<\/em><\/strong>. This is the ID of the thread that the parent thread waits for.<br><br><strong>Reference to return value<\/strong>: It is of type <strong><em>void **<\/em><\/strong>. The value of exiting thread is caught by this pointer.<br>Exiting the thread. Use pthread_exit(). This is written at the end of starting routine.<\/p>\n<\/div>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include&lt;stdio.h&gt;\n#include&lt;pthread.h&gt;\n\nint glb_val = 200;\n\nvoid *Calling_this_function( void *ptr )\n{\n        printf(&quot;Value  that was received during the starting routine: %d\\n &quot;,*(int*)ptr);\n        pthread_exit(&amp;glb_val);\n}\n\nvoid main()\n{\n        int the_arg = 10;\n        int *catch_thread=NULL; \/\/ pointer to an integer\n        pthread_t thread_ID;\n        pthread_create(&amp;thread_ID,NULL,Calling_this_function,&amp;the_arg); \/\/ Create the thread\n        pthread_join(thread_ID, (void**)&amp;catch_thread);  \n\/\/ Wait for other function and get value in the pointer.\n        printf(&quot;Value received by parent: %d\\n&quot;,*catch_thread);\n\n}\n<\/pre><\/div>\n\n\n<p class=\"has-black-color has-light-gray-background-color has-text-color has-background wp-block-paragraph\" style=\"font-size:15px;line-height:2.1;\"><strong>Execution:<\/strong><br>1) Execute with -lpthread<br>2) The program starts execution from main.<br>3) Creates a local variable for parent i.e the_arg.<br>4) Creates a pointer to catch value when the child thread returns i.e catch_thread<br>5) Creates variable for thread ID i.e thread_ID.<br>6) Creates a child thread at Calling_this_function() and pass the_arg as parameter.<br>7) Compiler identifies the Child thread i.e Calling_this_funciton()<br>8) Enters into the child thread i.e Calling_this_function()<br>9) Prints the statement with value as 10<br>10) Compiler waits for the child to die. I mean child process to end so that it can return and catch its value in catch_thread.<br>11) Execution of child process completed, return the reference to global variable glb_val.<br>12) Prints the global variable.<br>13) End of the program.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another simple program would be:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include&lt;stdio.h&gt;\n#include&lt;unistd.h&gt;\n#include&lt;stdlib.h&gt;\n#include&lt;pthread.h&gt;\n#include&lt;sys\/types.h&gt;\n#define Table_two 20\n#define Table_three 21\n#define Table_four 22\n#define Table_five 23\n#define UPTO 5\n\nvoid *TABLE_Two(void *ptr)\n{\n\tprintf(&quot;...Process ID of Table 2: %d...\\n&quot;,getpid());\n\n\twhile(1){\n\tint count;\n\tprintf(&quot;TWO TABLE: \\n&quot;);\n\tfor(count=1;count&lt;=UPTO;count++)\n\t{\n\t\tprintf(&quot; %d * %d =  %d\\n &quot;,Table_two,count,count*Table_two);\n\t\/\/\tsleep(1);\n\t\n\t}\n\tsleep(2);\n\t}\n\tpthread_exit(NULL);\n\n\t\n\n}\n\n\nvoid *TABLE_Three(void *ptr)\n{\n\tprintf(&quot;...Process ID of Table 3: %d...\\n&quot;,getpid());\n\n\twhile(1){\n\tint count;\n\tprintf(&quot;\\t\\tTHREE TABLE: \\n&quot;);\n\tfor(count=1;count&lt;=UPTO;count++)\n\t{\n\t\tprintf(&quot;\\t\\t %d * %d =  %d\\n &quot;,Table_three,count,count*Table_three);\n\t\/\/\tsleep(1);\n\t}\n\tsleep(2);\n\t}\n\tpthread_exit(NULL);\n\t\n\n}\n\n\nvoid *TABLE_Four(void *ptr)\n{\n\n\tprintf(&quot;...Process ID of Table 4: %d...\\n&quot;,getpid());\n\n\twhile(1){\n\tint count;\n\tprintf(&quot;\\t\\t\\t\\tFOUR TABLE: \\n&quot;);\n\tfor(count=1;count&lt;=UPTO;count++)\n\t{\n\t\tprintf(&quot;\\t\\t\\t\\t %d * %d =  %d\\n &quot;,Table_four,count,count*Table_four);\n\t\/\/\tsleep(1);\n\t}\n\tsleep(2);\n\t}\n\tpthread_exit(NULL);\n\t\n\n}\n\n\nvoid *TABLE_Five(void *ptr)\n{\n\tprintf(&quot;...Process ID of Table 5: %d...\\n&quot;,getpid());\n\n\twhile(1){\n\tint count;\n\tprintf(&quot;\\t\\t\\t\\t\\t\\tFIVE TABLE: \\n&quot;);\n\tfor(count=1;count&lt;=UPTO;count++)\n\t{\n\t\tprintf(&quot;\\t\\t\\t\\t\\t\\t %d * %d =  %d\\n &quot;,Table_five,count,count*Table_five);\n\t\/\/\tsleep(1);\n\t}\n\tsleep(2);\n\t}\n\tpthread_exit(NULL);\n\t\n}\n\n\n\nvoid main()\n{\n\n\tprintf(&quot;...Process ID of main: %d...\\n&quot;,getpid());\n\n\tpthread_t  thid&#x5B;4];\n\t\t\t\n\n\tpthread_create(&amp;thid&#x5B;0],NULL,TABLE_Two,NULL);\n\tpthread_create(&amp;thid&#x5B;1],NULL,TABLE_Three,NULL);\n\tpthread_create(&amp;thid&#x5B;2],NULL,TABLE_Four,NULL);  \t\n\tpthread_create(&amp;thid&#x5B;3],NULL,TABLE_Five,NULL);  \t\n\n\n\tpthread_join(thid&#x5B;0],NULL);\n\tpthread_join(thid&#x5B;1],NULL);\n\tpthread_join(thid&#x5B;2],NULL);\n\tpthread_join(thid&#x5B;3],NULL);\n\n\tprintf(&quot;\\n....End of threads execution...\\n&quot;);\n}\n\n<\/pre><\/div>\n\n\n<p class=\"has-black-color has-light-gray-background-color has-text-color has-background wp-block-paragraph\"><strong><em>On execution, you would find that all <\/em><\/strong>four threads would be running at the <strong><em>same time. <\/em><\/strong><\/p>\n\n\n\n<p class=\"has-white-color has-vivid-cyan-blue-to-vivid-purple-gradient-background has-text-color has-background wp-block-paragraph\"><strong><em>Feel free to modify and experiment.<\/em><\/strong><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s talk about Threads What is a Thread? &#8211; A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads. -A thread is an active entity as it executes as a part of a [&hellip;]<\/p>\n<a href=\"https:\/\/cthecosmos.com\/?p=3279\" class=\"more-link\">Read More <span class=\"screen-reader-text\">THREADS<\/span><\/a>","protected":false},"author":120055267,"featured_media":3285,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[1342,28627],"tags":[1634593,38887748,47974053,34939379,772321180,3383,55794,57505,255],"class_list":["post-3279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-education","category-embedded","tag-c-2","tag-embedded-2","tag-embedded-systems-2","tag-learning-2","tag-linux","tag-os","tag-processes","tag-threads","tag-ubuntu","fallback-thumbnail"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Let&#039;s talk about ThreadsWhat is a Thread?- A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.-A thread is an active entity as it executes as a part of a process. It goes\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yashwanth Naidu Tikkisetty\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/cthecosmos.com\/?p=3279\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Yashwanth Naidu Tikkisetty - Embedded Systems | Space Blogger\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"THREADS - Yashwanth Naidu Tikkisetty\" \/>\n\t\t<meta property=\"og:description\" content=\"Let&#039;s talk about ThreadsWhat is a Thread?- A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.-A thread is an active entity as it executes as a part of a process. It goes\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/cthecosmos.com\/?p=3279\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t\t<meta property=\"og:image:height\" content=\"1200\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2022-10-26T10:36:54+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2022-10-26T10:36:54+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"THREADS - Yashwanth Naidu Tikkisetty\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Let&#039;s talk about ThreadsWhat is a Thread?- A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.-A thread is an active entity as it executes as a part of a process. It goes\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#blogposting\",\"name\":\"THREADS - Yashwanth Naidu Tikkisetty\",\"headline\":\"THREADS\",\"author\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/cthecosmos.com\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/threads.jpg?fit=819%2C460&ssl=1\",\"width\":819,\"height\":460},\"datePublished\":\"2022-10-26T16:06:54+05:30\",\"dateModified\":\"2022-10-26T16:06:54+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#webpage\"},\"articleSection\":\"Education, Embedded, #c, #Embedded, #embedded systems, #learning, #linux, #OS, #processes, #threads, #ubuntu\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/cthecosmos.com\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=1342#listItem\",\"name\":\"Education\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=1342#listItem\",\"position\":2,\"name\":\"Education\",\"item\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=1342\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#listItem\",\"name\":\"THREADS\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#listItem\",\"position\":3,\"name\":\"THREADS\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=1342#listItem\",\"name\":\"Education\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Yashwanth Naidu Tikkisetty\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Yashwanth Naidu Tikkisetty\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#webpage\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279\",\"name\":\"THREADS - Yashwanth Naidu Tikkisetty\",\"description\":\"Let's talk about ThreadsWhat is a Thread?- A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.-A thread is an active entity as it executes as a part of a process. It goes\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/cthecosmos.com\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/threads.jpg?fit=819%2C460&ssl=1\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279\\\/#mainImage\",\"width\":819,\"height\":460},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3279#mainImage\"},\"datePublished\":\"2022-10-26T16:06:54+05:30\",\"dateModified\":\"2022-10-26T16:06:54+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#website\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"description\":\"Embedded Systems | Space Blogger\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"THREADS - Yashwanth Naidu Tikkisetty","description":"Let's talk about ThreadsWhat is a Thread?- A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.-A thread is an active entity as it executes as a part of a process. It goes","canonical_url":"https:\/\/cthecosmos.com\/?p=3279","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/cthecosmos.com\/?p=3279#blogposting","name":"THREADS - Yashwanth Naidu Tikkisetty","headline":"THREADS","author":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"publisher":{"@id":"https:\/\/cthecosmos.com\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/10\/threads.jpg?fit=819%2C460&ssl=1","width":819,"height":460},"datePublished":"2022-10-26T16:06:54+05:30","dateModified":"2022-10-26T16:06:54+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/cthecosmos.com\/?p=3279#webpage"},"isPartOf":{"@id":"https:\/\/cthecosmos.com\/?p=3279#webpage"},"articleSection":"Education, Embedded, #c, #Embedded, #embedded systems, #learning, #linux, #OS, #processes, #threads, #ubuntu"},{"@type":"BreadcrumbList","@id":"https:\/\/cthecosmos.com\/?p=3279#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/cthecosmos.com#listItem","position":1,"name":"Home","item":"https:\/\/cthecosmos.com","nextItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=1342#listItem","name":"Education"}},{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=1342#listItem","position":2,"name":"Education","item":"https:\/\/cthecosmos.com\/?cat=1342","nextItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?p=3279#listItem","name":"THREADS"},"previousItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?p=3279#listItem","position":3,"name":"THREADS","previousItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=1342#listItem","name":"Education"}}]},{"@type":"Person","@id":"https:\/\/cthecosmos.com\/#person","name":"Yashwanth Naidu Tikkisetty","image":{"@type":"ImageObject","@id":"https:\/\/cthecosmos.com\/?p=3279#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Yashwanth Naidu Tikkisetty"}},{"@type":"Person","@id":"https:\/\/cthecosmos.com\/?author=120055267#author","url":"https:\/\/cthecosmos.com\/?author=120055267","name":"Yashwanth Naidu Tikkisetty","image":{"@type":"ImageObject","@id":"https:\/\/cthecosmos.com\/?p=3279#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Yashwanth Naidu Tikkisetty"}},{"@type":"WebPage","@id":"https:\/\/cthecosmos.com\/?p=3279#webpage","url":"https:\/\/cthecosmos.com\/?p=3279","name":"THREADS - Yashwanth Naidu Tikkisetty","description":"Let's talk about ThreadsWhat is a Thread?- A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.-A thread is an active entity as it executes as a part of a process. It goes","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/cthecosmos.com\/#website"},"breadcrumb":{"@id":"https:\/\/cthecosmos.com\/?p=3279#breadcrumblist"},"author":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"creator":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/10\/threads.jpg?fit=819%2C460&ssl=1","@id":"https:\/\/cthecosmos.com\/?p=3279\/#mainImage","width":819,"height":460},"primaryImageOfPage":{"@id":"https:\/\/cthecosmos.com\/?p=3279#mainImage"},"datePublished":"2022-10-26T16:06:54+05:30","dateModified":"2022-10-26T16:06:54+05:30"},{"@type":"WebSite","@id":"https:\/\/cthecosmos.com\/#website","url":"https:\/\/cthecosmos.com\/","name":"Yashwanth Naidu Tikkisetty","description":"Embedded Systems | Space Blogger","inLanguage":"en-US","publisher":{"@id":"https:\/\/cthecosmos.com\/#person"}}]},"og:locale":"en_US","og:site_name":"Yashwanth Naidu Tikkisetty - Embedded Systems | Space Blogger","og:type":"article","og:title":"THREADS - Yashwanth Naidu Tikkisetty","og:description":"Let's talk about ThreadsWhat is a Thread?- A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.-A thread is an active entity as it executes as a part of a process. It goes","og:url":"https:\/\/cthecosmos.com\/?p=3279","og:image":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png","og:image:secure_url":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png","og:image:width":1200,"og:image:height":1200,"article:published_time":"2022-10-26T10:36:54+00:00","article:modified_time":"2022-10-26T10:36:54+00:00","twitter:card":"summary_large_image","twitter:title":"THREADS - Yashwanth Naidu Tikkisetty","twitter:description":"Let's talk about ThreadsWhat is a Thread?- A Thread is a path of execution within a process. A thread is also known as a lightweight process. The idea is to achieve parallelism by dividing a process into multiple threads.-A thread is an active entity as it executes as a part of a process. It goes","twitter:image":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png"},"aioseo_meta_data":{"post_id":"3279","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2025-08-31 20:13:00","updated":"2025-08-31 20:13:00","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/cthecosmos.com\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/cthecosmos.com\/?cat=1342\" title=\"Education\">Education<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tTHREADS\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/cthecosmos.com"},{"label":"Education","link":"https:\/\/cthecosmos.com\/?cat=1342"},{"label":"THREADS","link":"https:\/\/cthecosmos.com\/?p=3279"}],"jetpack_publicize_connections":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s8CiEf-threads","jetpack-related-posts":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/10\/threads.jpg?fit=819%2C460&ssl=1","_links":{"self":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/users\/120055267"}],"replies":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3279"}],"version-history":[{"count":24,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3279\/revisions"}],"predecessor-version":[{"id":3304,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3279\/revisions\/3304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/media\/3285"}],"wp:attachment":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}