1. init_mutex
During the compilation of Linux today, we found that init_temux always prompts an error.
After network searching, we found that the init_mutex function was abolished in Linux kernel versions 2.6.25 and later, and the new version was replaced by the sema_init function.
Platform: x86 32-bit
Kernel: 2.6.32
Definition:
Reference
Static
Inline
VoidInit_mutex (
StructSemaphore * SEM)
{
Sema_init (SEM, 1 );
}
Description: The init_mutex () function initializes the semaphores as mutex. Mutex is a special case of semaphores. It can prevent data from being read and written by two different systems.
Sema_init (SEM, 1) is defined:
Reference
Static
Inline
VoidSema_init (
StructSemaphore * SEM,
IntVal)
{
/*
** SEM = (struct semaphore) _ semaphore_initializer (* SEM), Val );
*
* I 'd rather use the more flexible initialization above, but sadly
* GCC 2.7.2.3 emits a bogus warning. egcs doesn't. Oh well.
*/
Atomic_set (& SEM-> count, Val );
SEM-> sleepers = 0;
Init_waitqueue_head (& SEM-> wait );
}
Sleepers: specifies the number of processes allowed to enter the critical section. The initialization value is 0 here.
Init_waitqueue_head ()
: Initialize a waiting queue header.
After init_mutex is abolished, replace the original init_mutex (SEM) with sema_init (SEM, 1 );
You can.
Reference Source: http://blog.csdn.net/ustcxjt/article/details/6916493
After network searching, we found that the init_mutex function was abolished in Linux kernel versions 2.6.25 and later, and the new version was replaced by the sema_init function.
Platform: x86 32-bit
Kernel: 2.6.32
Definition:
Reference
Static
Inline
VoidInit_mutex (
StructSemaphore * SEM)
{
Sema_init (SEM, 1 );
}
Description: The init_mutex () function initializes the semaphores as mutex. Mutex is a special case of semaphores. It can prevent data from being read and written by two different systems.
Sema_init (SEM, 1) is defined:
Reference
Static
Inline
VoidSema_init (
StructSemaphore * SEM,
IntVal)
{
/*
** SEM = (struct semaphore) _ semaphore_initializer (* SEM), Val );
*
* I 'd rather use the more flexible initialization above, but sadly
* GCC 2.7.2.3 emits a bogus warning. egcs doesn't. Oh well.
*/
Atomic_set (& SEM-> count, Val );
SEM-> sleepers = 0;
Init_waitqueue_head (& SEM-> wait );
}
Sleepers: specifies the number of processes allowed to enter the critical section. The initialization value is 0 here.
Init_waitqueue_head ()
: Initialize a waiting queue header.
After init_mutex is abolished, replace the original init_mutex (SEM) with sema_init (SEM, 1 );
You can.
Reference Source: http://blog.csdn.net/ustcxjt/article/details/6916493