Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cpu_switchto(9) [netbsd man page]

CPU_SWITCHTO(9) 					   BSD Kernel Developer's Manual					   CPU_SWITCHTO(9)

NAME
cpu_switchto -- machine-dependent LWP context switching interface SYNOPSIS
#include <sys/cpu.h> lwp_t * cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning); DESCRIPTION
The cpu_switchto() function saves the context of the LWP which is currently running on the processor, and restores the context of the LWP specified by newlwp. Remarks: 1. cpu_switchto() does not switch address spaces. 2. cpu_switchto() sets curlwp(9) to newlwp. If the architecture does non-interlocked adaptive mutex release, cpu_switchto() does an equivalent of membar_producer(3), before and after the modification of curlwp(9). 3. cpu_switchto() should be called at IPL_SCHED. When the function returns, the caller should lower the priority level as soon as possible. 4. cpu_switchto() might be called with spin mutexes held. The function takes the following arguments. oldlwp Specify the LWP from which the switch is going to be made, i.e., the calling LWP. If it was NULL, the context of the LWP currently running on this processor is not saved. newlwp Specify the LWP to which to switch. It must not be NULL. returning Only meaningful if the architecture implements fast software interrupts. If true, it indicates that oldlwp is a soft interrupt LWP that is blocking. It is a good indication that any kind of address space or user activity can be completely ignored. For example: ras_lookup(9), cache flushes, TLB wirings, adjusting lazy FPU state. All that is required is to restore the register state and stack, and return to the interrupted LWP. RETURN VALUES
The cpu_switchto() function does not return until another LWP calls cpu_switchto(). It returns the oldlwp argument of the cpu_switchto() which is called to switch back to our LWP. It is either a LWP which called cpu_switchto() to switch to us or NULL in case the LWP was exit- ing. SEE ALSO
membar_producer(3), swapcontext(3), intro(9), mutex(9), spl(9) BSD
June 2, 2011 BSD

Check Out this Related Man Page

LWP::Protocol::PSGI(3pm)				User Contributed Perl Documentation				  LWP::Protocol::PSGI(3pm)

NAME
LWP::Protocol::PSGI - Override LWP's HTTP/HTTPS backend with your own PSGI applciation SYNOPSIS
use LWP::UserAgent; use LWP::Protocol::PSGI; # can be Mojolicious, Catalyst ... any PSGI application my $psgi_app = do { use Dancer; setting apphandler => 'PSGI'; get '/search' => sub { return 'googling ' . params->{q}; }; dance; }; LWP::Protocol::PSGI->register($psgi_app); # can hijack any code or module that uses LWP::UserAgent underneath, with no changes my $ua = LWP::UserAgent->new; my $res = $ua->get("http://www.google.com/search?q=bar"); print $res->content; # "googling bar" DESCRIPTION
LWP::Protocol::PSGI is a module to hijack any code that uses LWP::UserAgent underneath such that any HTTP or HTTPS requests can be routed to your own PSGI application. Because it works with any code that uses LWP, you can override various WWW::*, Net::* or WebService::* modules such as WWW::Mechanize, without modifying the calling code or its internals. use WWW::Mechanize; use LWP::Protocol::PSGI; LWP::Protocol::PSGI->register($my_psgi_app); my $mech = WWW::Mechanize->new; $mech->get("http://amazon.com/"); # $my_psgi_app runs METHODS
register LWP::Protocol::PSGI->register($app); my $guard = LWP::Protocol::PSGI->register($app); Registers an override hook to hijack HTTP requests. If called in a non-void context, returns a Guard object that automatically resets the override when it goes out of context. { my $guard = LWP::Protocol::PSGI->register($app); # hijack the code using LWP with $app } # now LWP uses the original HTTP implementations unregister LWP::Protocol::PSGI->unregister; Resets all the overrides for LWP. If you use the guard interface described above, it will be automatically called for you. AUTHOR
Tatsuhiko Miyagawa <miyagawa@bulknews.net> COPYRIGHT
Copyright 2011- Tatsuhiko Miyagawa LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Plack::Client LWP::UserAgent perl v5.12.3 2011-05-12 LWP::Protocol::PSGI(3pm)
Man Page