Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux HostsFree MagazinesJobs
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > The Linux Kernel
Reload this Page Please explain arrayq_put() in arrayq.c
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

The Linux Kernel Compiling, theory, programming or other discussion about the linux kernel

Reply
 
Thread Tools Display Modes
Old 02-22-2008   #1 (permalink)
Just Joined!
 
Join Date: Feb 2008
Posts: 2
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;

actiononmail is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
 

Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix: Explain virtual_minimum_uid lbm_ Servers 0 01-16-2008 08:54 AM
Please explain... BTCruz The Coffee Lounge 38 01-02-2008 06:41 PM
How would you explain linux to the average joe? fanfan1313 The Coffee Lounge 7 01-23-2006 12:45 PM
Can someone explain this: writable partition becomes read-only ? pavlo_7 Misc 5 10-30-2005 04:55 AM
Could anyone explain this to me? Kelphyr Linux Newbie 4 10-03-2004 08:14 AM

Free Magazines
Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe
Systems Management News, the newspaper for IT systems administration and data center managers!
Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe
The Enterprise Newsweekly
eWeek is the essential technology information source for builders of e-business.
subscribe
Oracle Magazine
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe
Total Telecom
Total Telecom is "The Economist of the communications industry".
subscribe
More free magazines »



All times are GMT. The time now is 01:07 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.2.0