Function problem 1 init_emux

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.