Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to know how linux kernel used in Ubuntu manages concurrent access to shared data?

share|improve this question

Sir, I think you have a misconception about what locking is, and what mutex is for. Also, you have a misconception about what Ubuntu is.

Let's start with the latter: Ubuntu is a Linux-based distribution. Any and all low level system architecture components are done by the Linux kernel. Ubuntu is just a way of putting different software pieces together, configuring, installing and updating them in a robust, uniform and user-friendly fashion. Your question, thus, refers to Linux, and not Ubuntu.

Mutexes are used to make sure that common resources (such as memory) are not by mistake accessed and modified at the same time. Since processes in general do not share such resources as memory (neither in Windows nor in Linux), the problem arises when one uses threads, and not processes. This is done using mutexes, you are right in that; here you will find some more informations about that. Linux uses POSIX threads. However, whether you -- as a programmer -- use mutexes or something else (like spinlocks or critical section), that depends on you, not on the system (see here), be that Windows or Linux.

As for processes, one needs file locking, but that is a different story. And yes, processes are implemented differently in Windows and in Linux (most importantly, in scheduling; see this presentation to shed some light on that).

share|improve this answer
Yep, I do know everything. I used Ubuntu instead of linux, because Ubuntu also has its own kernel team. And I'm asking about how does linux manage concurrent access by different processes to the shared data. I'll edit the question. – green Sep 10 '12 at 9:15
up vote 0 down vote accepted

Before version 2.6, Linux was a nonpreemptive kernel. Now, it is fully preemptive, so a task can be preempted when it is running in the kernel.

The Linux kernel provides spinlocks and semaphores for locking in the kernel. On SMP machines the fundamental locking mechanism is a spinlock, and the kernel is designed so that the spinlock is held only for short durations.

This is not appropriate for single-processor machines. In single-processor machines, the kernel disables kernel preemption; and rather than releasing the spinlock, it eneables kernel preemption.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.