List Info

Thread: kevent: Timer notifications.




kevent: Timer notifications.
user name
2006-09-20 09:35:51
Timer notifications.

Timer notifications can be used for fine grained per-process
time 
management, since interval timers are very inconvenient to
use, 
and they are limited.

Signed-off-by: Evgeniy Polyakov <johnpol2ka.mitp.ru>

diff --git a/kernel/kevent/kevent_timer.c
b/kernel/kevent/kevent_timer.c
new file mode 100644
index 0000000..04acc46
--- /dev/null
+++ b/kernel/kevent/kevent_timer.c
 -0,0
+1,113 
+/*
+ * 2006 Copyright (c) Evgeniy Polyakov <johnpol2ka.mipt.ru>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it
and/or modify
+ * it under the terms of the GNU General Public License as
published by
+ * the Free Software Foundation; either version 2 of the
License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be
useful,
+ * but WITHOUT ANY WARRANTY; without even the implied
warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General
Public License
+ * along with this program; if not, write to the Free
Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 02111-1307  USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/hrtimer.h>
+#include <linux/jiffies.h>
+#include <linux/kevent.h>
+
+struct kevent_timer
+{
+	struct hrtimer		ktimer;
+	struct kevent_storage	ktimer_storage;
+	struct kevent		*ktimer_event;
+};
+
+static int kevent_timer_func(struct hrtimer *timer)
+{
+	struct kevent_timer *t = container_of(timer, struct
kevent_timer, ktimer);
+	struct kevent *k = t->ktimer_event;
+
+	kevent_storage_ready(&t->ktimer_storage, NULL,
KEVENT_MASK_ALL);
+	hrtimer_forward(timer, timer->base->softirq_time,
+			ktime_set(k->event.id.raw[0],
k->event.id.raw[1]));
+	return HRTIMER_RESTART;
+}
+
+static struct lock_class_key kevent_timer_key;
+
+static int kevent_timer_enqueue(struct kevent *k)
+{
+	int err;
+	struct kevent_timer *t;
+
+	t = kmalloc(sizeof(struct kevent_timer), GFP_KERNEL);
+	if (!t)
+		return -ENOMEM;
+
+	hrtimer_init(&t->ktimer, CLOCK_MONOTONIC,
HRTIMER_REL);
+	t->ktimer.expires = ktime_set(k->event.id.raw[0],
k->event.id.raw[1]);
+	t->ktimer.function = kevent_timer_func;
+	t->ktimer_event = k;
+
+	err = kevent_storage_init(&t->ktimer,
&t->ktimer_storage);
+	if (err)
+		goto err_out_free;
+	lockdep_set_class(&t->ktimer_storage.lock,
&kevent_timer_key);
+
+	err = kevent_storage_enqueue(&t->ktimer_storage,
k);
+	if (err)
+		goto err_out_st_fini;
+
+	printk("%s: jiffies: %lu, timer: %p.\n",
__func__, jiffies, &t->ktimer);
+	hrtimer_start(&t->ktimer, t->ktimer.expires,
HRTIMER_REL);
+
+	return 0;
+
+err_out_st_fini:
+	kevent_storage_fini(&t->ktimer_storage);
+err_out_free:
+	kfree(t);
+
+	return err;
+}
+
+static int kevent_timer_dequeue(struct kevent *k)
+{
+	struct kevent_storage *st = k->st;
+	struct kevent_timer *t = container_of(st, struct
kevent_timer, ktimer_storage);
+
+	hrtimer_cancel(&t->ktimer);
+	kevent_storage_dequeue(st, k);
+	kfree(t);
+
+	return 0;
+}
+
+static int kevent_timer_callback(struct kevent *k)
+{
+	k->event.ret_data[0] = jiffies_to_msecs(jiffies);
+	return 1;
+}
+
+static int __init kevent_init_timer(void)
+{
+	struct kevent_callbacks tc = {
+		.callback = &kevent_timer_callback,
+		.enqueue = &kevent_timer_enqueue,
+		.dequeue = &kevent_timer_dequeue};
+
+	return kevent_add_callbacks(&tc, KEVENT_TIMER);
+}
+module_init(kevent_init_timer);
+

-
To unsubscribe from this list: send the line
"unsubscribe linux-kernel" in
the body of a message to majordomovger.kernel.org
More majordomo info at  http://vge
r.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

request for help, cgi downgraded from zoom to net::z3950 0.32
user name
2006-09-20 09:07:32
Greetings,

I had a cgi running beautifully under Linux that used
the ZOOM module. 

I switched my webserver to NetBSD 3.0, but it seems
that the  people that port software to the NetBSD
pkg/pkgsrc system   are a bit behind the times. They
include only the old Net::Z3950 version 0.32. 
ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/net/p5-Net-Z
3950/README.html
(and as for yaz, they ported 2.1.6). 

I have tried installing ZOOM in alternative ways, but
it seems that for now I have to tweak the cgi script
to make it run with the module I have. 

So here it is, 
right now it shows no error message, but no books
either. WOuld you please help me point to errors? 

#!/usr/pkg/bin/perl -wT
# Please maintain always, always, this line up!
# Little script, to learn how
# 1) to get a textarea
# 2) parse each line,
#   2.1) isolate "author" if needed,
# 3) make a z39.50/zoom search having those terms as
keywords,
# 4) reprint the content to a webpage
#  -----
#  zoom es una implementaci\xc3\x83\xc2\xb3n del
protocolo z39.50
# de transferencia de informaci\xc3\x83\xc2\xb3n
bibliogr\xc3\x83\xc2\xa1fica
#  http://zoom.z3950.org
#
#  Modulos necesarios:
#    http://se
arch.cpan.org/~mirk/Net-Z3950-ZOOM
#    que a su vez necesita el yaz toolkit en C
#       http://www.indexdata.dk/
yaz/
#
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
#use ZOOM;
use Net::Z3950;
use Text::Unaccent;

my $host ="voyprod.pitt.edu";
my $port =7090;
# $host y $port corresponden al servidor de z3950
# de la U. de Pittsburgh
# z3950.loc.gov:7090 para Library of congress
# fsz3950.oclc.org:210 para OCLC
#

my $query = CGI::new();
my $bookWords = $query->param("BookWords");


my bookTitle = split(/\n/,$bookWords);

#my mgr = new Net::Z3950
my $conn = new Net::Z3950::Connection($host, $port,
databaseName =>"VOYAGER");
# $conn->option(preferredRecordSyntax =>
"USMARC");

print header();
print start_html("Results from your search...");
print "<h2>Results from your
search</h2>\n";


# for every line...
foreach $item (bookTitle) {

  print p("processing line ");
  print $item;
  $mynewitem = unac_string("UTF8",$item);
  # $
   $myquery = "\attr 1=4 \attr 3=1 \attr 4=1
\attr
5=1 \"" . $mynewitem . "\
"";
    # 1=4 means search in title field,
    # 4=1 means search as phrase -- al words in that
    #        order
    # 5=1 means truncated left and right
    # all according to  bib1 attributes

   $rs = $conn->search(-prefix => $myquery);

   $n = $rs->size();
  # $n is the number of records of the retrieved set.

#  # impresion en pantalla de cada record
   for $i (1 .. $n) {
      $rec = $rs->record($i-1);
     print "<pre>";
     print $rec->render();
     print "</pre>";
     print "<hr>";
    }

   # };
   # if ($) {
   #     print "Error ", $->code(), ":
",
$->message(), "\n";
   # }
}
print "</body></html>\n";

--------------------------------
the html page is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.or
g/TR/html4/loose.dtd">
<html>

<head>
  <title></title>
  <meta name="GENERATOR"
content="Quanta Plus">
</head>
<body>
<h2></h2>
Enter the list of book titles to be searched, one
title per line. 
<FORM method="POST" 
      action="http://192.168.3
.2/cgi-bin/busca.cgi" 
     
enctype="application/x-www-form-urlencoded">
   <textarea cols="50"
name="BookWords" rows="15"
wrap="physical"></textarea>

       
<INPUT type="submit">
</FORM>

</body>
</html>




htt
p://socioenlinea.blog.lemonde.fr/socioenlinea/
Comentarios sobre politica, sociedad y ciencia social.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection
around 
http://mail.yahoo.com 

_______________________________________________
Net-z3950 mailing list
Net-z3950lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/n
et-z3950
request for help, cgi downgraded from zoom to net::z3950 0.32
user name
2006-09-20 10:07:20
Juan Zuluaga writes:
 > I had a cgi running beautifully under Linux that used
 > the ZOOM module. 
 > [...]
 > #use ZOOM;
 > use Net::Z3950;

No, this is not using the ZOOM module but its deprecated
predecessor
the Net::Z2950 module.  Please upgrade to ZOOM-Perl, which
is part of
the Net::Z3950::ZOOM module on CPAN.  It is much, much
better (and
more supported!)

 _/|_	
____________________________________________________________
_______
/o ) \/  Mike Taylor    <mikeindexdata.com>    http://www.miketaylor.or
g.uk
)_v__/\  "Boldly, brave Sir Robin rode forth from
Camelot, / He was not
	 afraid to die, ho brave Sir Robin, / He was not the least
bit
	 scared to be killed in nasty ways, / Brave, brave, brave,
brave
	 Sir Robin" -- Monty Python and the Holy Grail.


_______________________________________________
Net-z3950 mailing list
Net-z3950lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/n
et-z3950
request for help, cgi downgraded from zoom to net::z3950 0.32
user name
2006-09-20 10:07:20
Juan Zuluaga writes:
 > I had a cgi running beautifully under Linux that used
 > the ZOOM module. 
 > [...]
 > #use ZOOM;
 > use Net::Z3950;

No, this is not using the ZOOM module but its deprecated
predecessor
the Net::Z2950 module.  Please upgrade to ZOOM-Perl, which
is part of
the Net::Z3950::ZOOM module on CPAN.  It is much, much
better (and
more supported!)

 _/|_	
____________________________________________________________
_______
/o ) \/  Mike Taylor    <mikeindexdata.com>    http://www.miketaylor.or
g.uk
)_v__/\  "Boldly, brave Sir Robin rode forth from
Camelot, / He was not
	 afraid to die, ho brave Sir Robin, / He was not the least
bit
	 scared to be killed in nasty ways, / Brave, brave, brave,
brave
	 Sir Robin" -- Monty Python and the Holy Grail.


_______________________________________________
Net-z3950 mailing list
Net-z3950lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/n
et-z3950
request for help, cgi downgraded from zoom to net::z3950 0.32
user name
2006-09-20 10:07:20
Juan Zuluaga writes:
 > I had a cgi running beautifully under Linux that used
 > the ZOOM module. 
 > [...]
 > #use ZOOM;
 > use Net::Z3950;

No, this is not using the ZOOM module but its deprecated
predecessor
the Net::Z2950 module.  Please upgrade to ZOOM-Perl, which
is part of
the Net::Z3950::ZOOM module on CPAN.  It is much, much
better (and
more supported!)

 _/|_	
____________________________________________________________
_______
/o ) \/  Mike Taylor    <mikeindexdata.com>    http://www.miketaylor.or
g.uk
)_v__/\  "Boldly, brave Sir Robin rode forth from
Camelot, / He was not
	 afraid to die, ho brave Sir Robin, / He was not the least
bit
	 scared to be killed in nasty ways, / Brave, brave, brave,
brave
	 Sir Robin" -- Monty Python and the Holy Grail.


_______________________________________________
Net-z3950 mailing list
Net-z3950lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/n
et-z3950
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )