02-08-2004
Unix Internals really isn't a subject for a layman. You can write an overview, but then you would not mention a structure like a hash queue. Typically books like that assume that the reader is a very experienced C programmer. I don't know any good unix internals sites.
A little context would help here. I'm guessing that you have a rather old unix internals book and that you're referring to the buffer cache.
Let's say that a program wants to read the first few bytes of /etc/hosts. The kernel will need the first block of that file in a buffer. First it needs to figure out which block that is... let's say that it is block 6923 of filesystem number 1. Maybe that block is currently in core. So the kernel looks for 1:6923. And it looks in the hash queues.
But let's say it didn't find it. So it needs a free block. It will take the oldest block off the free list and read the data. After the data arrives in the block, the kernel can copy some of it to program. That finishes the read system call. So it puts the block at the end of the free list.
Now the block is in a hash queue and the free list.
If another program wants that block, it will succeed when it looks in the right hash queue. It will take the block off the free list, use it, and put it back at the end of the free list.
But if it doesn't get used again, it will drift towars the top of the free list and eventually it gets used for something else.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi,
I am working closly with unix message queues i have encountered the following -
after creating the Q and start working with it (pushing & pulling) i receive the following stange parameters on the q's -
STIME=no_entry
Qnum=0
CBYTES=4140
when this happens, the Q is disabled (meaning i... (3 Replies)
Discussion started by: kel
3 Replies
2. Shell Programming and Scripting
I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes).
Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash.
Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies
3. Programming
Hello !!!!! I have a simple question but i can't find the answer anywhere hope to meet it here.
Why it is a bad idea to pass pointers through message queues ?
Most structs i see all of their char types are arrays... Is it becase having pointers means we could possibily send wrong bytes ?
For... (2 Replies)
Discussion started by: qlyine
2 Replies
4. UNIX for Advanced & Expert Users
Hello,
i was wondering if you could assist me in the following situation:
i am trying to queue a group execution commands (same command but different parameters) submited from an openVMS system to a Unix system (HP UX). The commands should run in sequence; the next starts after prev finish... (5 Replies)
Discussion started by: wede23
5 Replies
5. Shell Programming and Scripting
Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below.
#!/usr/bin/perl
use warnings;
use Tie::IxHash;
use strict;
tie (my %programs, "Tie::IxHash");
while (my $line = <DATA>) {
chomp $line;
my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies
6. Shell Programming and Scripting
Hi,
In Perl, is it possible to use a range of numbers with '..' as a key in a hash?
Something in like:
%hash = (
'768..1536' => '1G',
'1537..2560' => '2G'
);
That is, the range operation is evaluated, and all members of the range are... (3 Replies)
Discussion started by: dsw
3 Replies
7. UNIX for Dummies Questions & Answers
Hi all,
I just downloaded this example from the net. I was looking around for a hash table like implementation in unix when I came across this.
ARRAY=( "cow:moo"
"dinosaur:roar"
"bird:chirp"
"bash:rock" )
for animal in ${ARRAY} ; do
KEY=${animal%%:*}
... (8 Replies)
Discussion started by: anindyabecs
8 Replies
8. Shell Programming and Scripting
Hi,
I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all .
my %result (
$abc => {
'data_count' => '10',
'ID' => 'ABC122',
}
$def => {
'data_count' => '20',
'ID' => 'defASe',
... (1 Reply)
Discussion started by: asak
1 Replies
9. Shell Programming and Scripting
Hello gurus, Iam trying to parse following BibTex file (bibliography.bib):
@book{Lee2000a,
abstract = {Abstract goes here},
author = {Lee, Wenke and Stolfo, Salvatore J},
title = {{Data mining approaches for intrusion detection}},
year = {2000}
}
@article{Forrest1996,
abstract =... (0 Replies)
Discussion started by: wakatana
0 Replies
10. Shell Programming and Scripting
Hi, I have a hash of hash where it has
name, activities and count
i have data like this -
$result->{$name}->{$activities} = $value;
content of that are -
name - robert tom cat peter
activities - running, eating, sleeping , drinking, work
i need to print output as below
... (3 Replies)
Discussion started by: asak
3 Replies
LEARN ABOUT OPENSOLARIS
copyb
copyb(9F) Kernel Functions for Drivers copyb(9F)
NAME
copyb - copy a message block
SYNOPSIS
#include <sys/stream.h>
mblk_t *copyb(mblk_t *bp);
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
PARAMETERS
bp Pointer to the message block from which data is copied.
DESCRIPTION
The copyb() function allocates a new message block, and copies into it the data from the block that bp denotes. The new block will be at
least as large as the block being copied. copyb() uses the b_rptr and b_wptr members of bp to determine how many bytes to copy.
RETURN VALUES
If successful, copyb() returns a pointer to the newly allocated message block containing the copied data. Otherwise, it returns a NULL
pointer.
CONTEXT
The copyb() function can be called from user, interrupt, or kernel context.
EXAMPLES
Example 1 Using copyb
For each message in the list, test to see if the downstream queue is full with the canputnext(9F) function (line 21). If it is not full,
use copyb to copy a header message block, and dupmsg(9F) to duplicate the data to be retransmitted. If either operation fails, reschedule a
timeout at the next valid interval.
Update the new header block with the correct destination address (line 34), link the message to it (line 35), and send it downstream (line
36). At the end of the list, reschedule this routine.
1 struct retrans {
2 mblk_t *r_mp;
3 int r_address;
4 queue_t *r_outq;
5 struct retrans *r_next;
6 };
7
8 struct protoheader {
...
9 int h_address;
...
10 };
11
12 mblk_t *header;
13
14 void
15 retransmit(struct retrans *ret)
16 {
17 mblk_t *bp, *mp;
18 struct protoheader *php;
19
20 while (ret) {
21 if (!canputnext(ret->r_outq)) { /* no room */
22 ret = ret->r_next;
23 continue;
24 }
25 bp = copyb(header); /* copy header msg. block */
26 if (bp == NULL)
27 break;
28 mp = dupmsg(ret->r_mp); /* duplicate data */
29 if (mp == NULL) { /* if unsuccessful */
30 freeb(bp); /* free the block */
31 break;
32 }
33 php = (struct protoheader *)bp->b_rptr;
34 php->h_address = ret->r_address; /* new header */
35 bp->bp_cont = mp; /* link the message */
36 putnext(ret->r_outq, bp); /* send downstream */
37 ret = ret->r_next;
38 }
39 /* reschedule */
40 (void) timeout(retransmit, (caddr_t)ret, RETRANS_TIME);
41 }
SEE ALSO
allocb(9F), canputnext(9F), dupmsg(9F)
Writing Device Drivers
STREAMS Programming Guide
SunOS 5.11 16 Jan 2006 copyb(9F)