{"id":125,"date":"2012-11-18T13:59:07","date_gmt":"2012-11-18T13:59:07","guid":{"rendered":"http:\/\/finaldie.com\/wordpress\/?p=125"},"modified":"2012-11-18T14:15:50","modified_gmt":"2012-11-18T14:15:50","slug":"how-many-mutex-objects-can-exist-at-the-same-time","status":"publish","type":"post","link":"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/","title":{"rendered":"How many mutex objects can exist at the same time?"},"content":{"rendered":"<p>Okie, for this question, I remember that a interviewer has asked me before, unfortunately I didn&#8217;t know how to answer this question at that time. But the answer <span style=\"color: #333333; font-style: normal; line-height: 24px;\">he gave me is<\/span>\u00a0not very correct when I know the truth.<\/p>\n<p>First, let&#8217;s go through the truth:\u00a0<strong><em>There is no explicit maximum count for the number of mutex objects which may exist simultaneously within an application or on a system in general. Considering this and the fact that mutexes are not required to be created at the kernel level and kernel specific resources are not consumed, most systems are normally limited only by the amount of memory available.<\/em><\/strong><\/p>\n<p>So, it is limited by memory, but not kernel, if there is no enough available memory for us, we can not alloc a new lock. For some hash table structure, if we want to avoid concurrent, we can alloc a lock per key if there is still enough memory available. But lock is still cost memory, if the concurrent is not very high, or the memory is very limit for us, we need to attend it. For this solution, we can alloc limited locks at start, so the\u00a0collision probability is &#8220;hash(key) \/ locks&#8221;, in the best situation, there is no collision occur, the worst situation, all keys will be blocked by one lock, this need to analysis by online data.<\/p>\n<p>Hope this will be a little bit help. \u00a0:D<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okie, for this question, I remember that a interviewer has asked me before, unfortunately I didn&#8217;t know how to answer this question at that time. But the answer he gave me is\u00a0not very correct when I know the truth. First, let&#8217;s go through the truth:\u00a0There is no explicit maximum count for the number of mutex &#8230; <a title=\"How many mutex objects can exist at the same time?\" class=\"read-more\" href=\"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/\" aria-label=\"More on How many mutex objects can exist at the same time?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How many mutex objects can exist at the same time? - Final Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How many mutex objects can exist at the same time? - Final Blog\" \/>\n<meta property=\"og:description\" content=\"Okie, for this question, I remember that a interviewer has asked me before, unfortunately I didn&#8217;t know how to answer this question at that time. But the answer he gave me is\u00a0not very correct when I know the truth. First, let&#8217;s go through the truth:\u00a0There is no explicit maximum count for the number of mutex ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/\" \/>\n<meta property=\"og:site_name\" content=\"Final Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hu.yuzhang\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-18T13:59:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-11-18T14:15:50+00:00\" \/>\n<meta name=\"author\" content=\"final\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hyzwowtools\" \/>\n<meta name=\"twitter:site\" content=\"@hyzwowtools\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"final\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/\",\"url\":\"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/\",\"name\":\"How many mutex objects can exist at the same time? - Final Blog\",\"isPartOf\":{\"@id\":\"https:\/\/finaldie.com\/blog\/#website\"},\"datePublished\":\"2012-11-18T13:59:07+00:00\",\"dateModified\":\"2012-11-18T14:15:50+00:00\",\"author\":{\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3\"},\"breadcrumb\":{\"@id\":\"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/finaldie.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How many mutex objects can exist at the same time?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/finaldie.com\/blog\/#website\",\"url\":\"https:\/\/finaldie.com\/blog\/\",\"name\":\"Final Blog\",\"description\":\"As simple as possible...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/finaldie.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3\",\"name\":\"final\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g\",\"caption\":\"final\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How many mutex objects can exist at the same time? - Final Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/","og_locale":"en_US","og_type":"article","og_title":"How many mutex objects can exist at the same time? - Final Blog","og_description":"Okie, for this question, I remember that a interviewer has asked me before, unfortunately I didn&#8217;t know how to answer this question at that time. But the answer he gave me is\u00a0not very correct when I know the truth. First, let&#8217;s go through the truth:\u00a0There is no explicit maximum count for the number of mutex ... Read more","og_url":"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/","og_site_name":"Final Blog","article_publisher":"https:\/\/www.facebook.com\/hu.yuzhang","article_published_time":"2012-11-18T13:59:07+00:00","article_modified_time":"2012-11-18T14:15:50+00:00","author":"final","twitter_card":"summary_large_image","twitter_creator":"@hyzwowtools","twitter_site":"@hyzwowtools","twitter_misc":{"Written by":"final","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/","url":"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/","name":"How many mutex objects can exist at the same time? - Final Blog","isPartOf":{"@id":"https:\/\/finaldie.com\/blog\/#website"},"datePublished":"2012-11-18T13:59:07+00:00","dateModified":"2012-11-18T14:15:50+00:00","author":{"@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3"},"breadcrumb":{"@id":"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/finaldie.com\/blog\/how-many-mutex-objects-can-exist-at-the-same-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/finaldie.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How many mutex objects can exist at the same time?"}]},{"@type":"WebSite","@id":"https:\/\/finaldie.com\/blog\/#website","url":"https:\/\/finaldie.com\/blog\/","name":"Final Blog","description":"As simple as possible...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/finaldie.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3","name":"final","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g","caption":"final"}}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/125"}],"collection":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/comments?post=125"}],"version-history":[{"count":3,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"predecessor-version":[{"id":127,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/125\/revisions\/127"}],"wp:attachment":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}