What is a completion and how to use one on linux kernel 3.10

What’s a completition ?
A completition is like a kernel’s semaphore which starts blocked.
But why don’t I use a semaphore that starts blocked ?
That’s why The semaphores have been heavily optimized for the “available” case.

kernel example code here

The device node that we are gonna utilize!

note : the major number was found when I saw the ouput of dmesg command after I inserted the new kernel module with the insmod command.

[eplauchu@lapMine ~]# mknod /dev/completition_practice_driver c 247 0

Compile & Test

— Step 1
We’ve got to compile and run this on the linux terminal A then we will have to type the letter ‘r’ (The process will get on a awaiting state)

[root@lapMine completition]# g++ testcomp.cpp
[root@lapMine completition]# ./a.out
r

— Step 2
We’ve got to run this on the linux terminal B.

[root@lapMine completition]# ./a.out
w

— Step 3
Check how the second process frees the completition of the step 1 process.

[root@lapMine completition]# ./a.out
r
Reading Data from virtual device 123456789

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s