Re: shared variable usage in memcached
On Mar 30, 9:24 am, Gabrielle wrote: > Heya, > > I'm a PhD student at the University of Southampton. I'm researching > the how multi-threaded software uses shared resources such as shared > state and message passing over networks etc, and how those uses change > across software versions. I want to read through the source code but > don't have a great understanding of multi-threaded C so if anyone > could give me pointers or a general description about how the shared > variables/condition variables are used and for what conceptual purpose > I would be much obliged. In summary: C doesn't support multi-threading. There are primitives that will split a process into either two distinct processes (no ability to share directly) or spawn a thread starting with another function call. All memory available to a process is available to all threads. It is up to the programmer to access this memory safely. posix threads provides locking primitives that come with some memory barriers as well as some condition mechanisms to wait for signal from other threads. But you're pretty well on your own. Our structures in memcached primarily fall into one of two categories: 1) shared access via locks whenever needed (e.g. the thing that holds all your data) 2) copied per-thread and aggregated via special shared access functions (e.g. stats) Clocks are accessed lazily because time is somewhat advisory, so access to current time is something that would raise a yellow flag. In isolation, it's possible for time to stop to a thread, but in practice, an unrelated memory barrier will cause synchronization of the thread cache often enough to have it not be harmful. To unsubscribe from this group, send email to memcached+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Re: Building development builds of memcached on Windows
Very good to hear! Thanks for all of your work on this. Having a predictable path to future versions on Windows will help us feel comfortable with expanding our scope of memcache usage. Stephen Johnston On Tue, Mar 30, 2010 at 5:06 AM, Trond Norbye wrote: > Hi, > > I'm really excited to tell you all that I've just released a bunch of > changesets that allows you to build the latest development builds of the > engine branch on Microsoft Windows. I wrote up a small blog post to help > people get started: > http://trondn.blogspot.com/2010/03/building-memcached-windows.html > > A number of people contributed to make this possible, but I would like to > highlight Patrick Galbraith for driving this forward! Thanks! > > The update includes more enhancements and bugfixes contributed by > NorthScale: > * isasl support > * topkeys support > * extension api to allow you to dynamically load modules with extra > functionality > * Refactored connection pool to use the object cache > > You can find the complete source code > http://github.com/trondn/memcached/tree/engine > > Happy hacking, > > Trond > > To unsubscribe from this group, send email to memcached+ > unsubscribegooglegroups.com or reply to this email with the words "REMOVE > ME" as the subject. > To unsubscribe from this group, send email to memcached+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
shared variable usage in memcached
Heya, I'm a PhD student at the University of Southampton. I'm researching the how multi-threaded software uses shared resources such as shared state and message passing over networks etc, and how those uses change across software versions. I want to read through the source code but don't have a great understanding of multi-threaded C so if anyone could give me pointers or a general description about how the shared variables/condition variables are used and for what conceptual purpose I would be much obliged. Thanks, Gabrielle To unsubscribe from this group, send email to memcached+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Issue 127 in memcached: incr/decr operations are not thread safe.
Status: New Owner: Labels: Type-Defect Priority-Medium New issue 127 by sadao.hiratsuka: incr/decr operations are not thread safe. http://code.google.com/p/memcached/issues/detail?id=127 incr/decr operations are not thread safe. - What steps will reproduce the problem? Please use this code to reproduce the problem. http://gist.github.com/348889 $ memcached -t 16 $ ./test_ascii expected: 10 result: 99939 Change this line to use binary protocol and test again. bool g_binary = true; $ ./test_binary expected: 10 result: 99927 - What version of the product are you using? On what operating system? memcached 1.4.4 Red Hat Enterprise Linux 5.4 x86_64 - Please provide any additional information below. Here is a sample patch to fix the problem. *** memcached.c_org 2009-11-27 14:45:13.0 +0900 --- memcached.c 2010-03-31 01:29:22.0 +0900 *** *** 54,59 --- 54,60 #endif #endif + pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER; /* * forward declarations */ *** *** 1017,1022 --- 1018,1024 req->message.body.expiration); } + pthread_mutex_lock(&incr_lock); it = item_get(key, nkey); if (it && (c->binary_header.request.cas == 0 || c->binary_header.request.cas == ITEM_get_cas(it))) { *** *** 1082,1087 --- 1084,1090 write_bin_error(c, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0); } + pthread_mutex_unlock(&incr_lock); } static void complete_update_bin(conn *c) { *** *** 2780,2785 --- 2783,2789 return; } + pthread_mutex_lock(&incr_lock); it = item_get(key, nkey); if (!it) { pthread_mutex_lock(&c->thread->stats.mutex); *** *** 2791,2796 --- 2795,2801 pthread_mutex_unlock(&c->thread->stats.mutex); out_string(c, "NOT_FOUND"); + pthread_mutex_unlock(&incr_lock); return; } *** *** 2806,2811 --- 2811,2817 break; } item_remove(it); /* release our reference */ + pthread_mutex_unlock(&incr_lock); } /* Thanks. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings To unsubscribe from this group, send email to memcached+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Building development builds of memcached on Windows
Hi, I'm really excited to tell you all that I've just released a bunch of changesets that allows you to build the latest development builds of the engine branch on Microsoft Windows. I wrote up a small blog post to help people get started: http://trondn.blogspot.com/2010/03/building-memcached-windows.html A number of people contributed to make this possible, but I would like to highlight Patrick Galbraith for driving this forward! Thanks! The update includes more enhancements and bugfixes contributed by NorthScale: * isasl support * topkeys support * extension api to allow you to dynamically load modules with extra functionality * Refactored connection pool to use the object cache You can find the complete source code http://github.com/trondn/memcached/tree/engine Happy hacking, Trond To unsubscribe from this group, send email to memcached+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.