LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 02-22-2008, 02:38 AM   #1
actiononmail
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
Unhappy Please explain arrayq_put() in arrayq.c


Hi ,

I am a novice programmer in Device Driver and Kernel Programming.I have come through a function in arrayq.c whose main work is to put element in the Queue.The function is given below:-

int arrayq_put(arrayq_t *q, void *base, arrayq_elem_t *data)
{
spin_lock(&q->lock);

if (arrayq_full(q))
{
spin_unlock(&q->lock);
return 10;
}
if ((data->size + sizeof(arrayq_elem_t)) > q->elem_size)
{
printk ("<%d> <%d> : <%d>\n", data->size, sizeof(arrayq_elem_t), q->elem_size);
spin_unlock(&q->lock);

return 0;
}
memcpy(base + q->put * q->elem_size,
data,
data->size + sizeof(arrayq_elem_t));
q->put++;
q->put &= q->mask;

spin_unlock(&q->lock);
return 1;
}
The thing here I don't understand is use of arrayq_elem_t *data which is used both as Source Pointer and Size in memcpy() method.The various structure used are given as follows:-

typedef struct
{
unsigned exponent;
unsigned size;
unsigned mask;
unsigned put;
unsigned get;
unsigned elem_size;
spinlock_t lock;
}
arrayq_t;

typedef struct
{
unsigned size;
}
arrayq_elem_t;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can someone explain this to me, please? Hammett Linux - Software 3 02-16-2006 08:02 PM
explain. bruse Linux - Newbie 6 09-08-2005 11:48 PM
Can somebody explain this to me? SyBEX Linux - Software 3 10-24-2004 05:32 PM
can anyone explain this? log Linux - Software 2 06-10-2003 12:30 AM
Please explain pilotgi Linux - Software 9 05-09-2002 06:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 07:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration