Any bad side-effects to lengthy blocking in native code? - crosspost

[This question was also posted on the Native Methods forum a day ago, so far no response]
1) Are there any negative side-effects to having one (or maybe a few) Java threads block for an extended period (e.g. hours) in native code? Naturally the thread would NOT be one of the "special" threads (such as the Swing event dispatcher, etc).
2) Does the answer vary by platform? I'm interested in Win32, Linux and possibly Solaris (in that order).
3) What if I scale the number of threads blocked in JNI code up to 100 threads. Does that change any of the answers? This is perhaps a silly number, I'm just trying to understand if more resources are consumed by blocking in the JNI as opposed to blocking in Java.
4) Do modern JVM's use one native thread per Java thread? If so, then I would guess there is really nothing special about blocking in native code.
Lastly, Is this stuff spelled out in some document? Or is there some newsgroup dedicated to the topic? I looked a comp.lang.java.machine, but there is nothing there but spam.
Motivation for query -- In my application I need to interface with legacy C++ code that blocks (mostly on socket and i/o selects). I'm not thrilled about native code, but if there are no serious side-effects to extended blocking, it may be a viable approach.

[This question was also posted on the Native Methods
forum a day ago, so far no response]
1) Are there any negative side-effects to having one
(or maybe a few) Java threads block for an extended
period (e.g. hours) in native code? Naturally the
thread would NOT be one of the "special" threads (such
as the Swing event dispatcher, etc).No. It is common to have a "reader" thread for a blocking socket connection. This results in a block in native code for days (months). The only impact is that you may end up creating alot of threads to handle this blocking code.
>
2) Does the answer vary by platform? I'm interested in Win32, Linux and possibly Solaris (in that order).I would hope not. You may find that WIn32 will run out of threads fairly quickly (at about 1000 threads) Earlier versions of Linux create a different process per thread which can have a non-trival overhead. Solaris will probibly not care. It has a thread number limit but if you reach it you are probibly doing something wroung.
>
3) What if I scale the number of threads blocked in
JNI code up to 100 threads. Does that change any of
the answers? This is perhaps a silly number, I'm just
trying to understand if more resources are consumed by
blocking in the JNI as opposed to blocking in Java.It takes a while to start a thread, it also consumes a minimal amount of per thread memory which can add up if you have 100s of threads. f you are writing the JNI I would suggest writing it to scale such that say more connections/files etc can be handled by a small number of threads (like NIO does) and these issues are reduced.
>
Motivation for query -- In my application I need to
interface with legacy C++ code that blocks (mostly on
socket and i/o selects). I'm not thrilled about native
code, but if there are no serious side-effects to
extended blocking, it may be a viable approach.See above.

Similar Messages

  • Any bad side-effects to lengthy blocking in native code? (Win32,Linux,Solar

    1) Are there any negative side-effects to having one (or maybe a few) Java threads block for an extended period (e.g. hours) in native code? Naturally the thread would NOT be one of the "special" threads (such as the Swing event dispatcher, etc).
    2) Does the answer vary by platform? I'm interested in Win32, Linux and possibly Solaris (in that order).
    3) What if I scale the number of threads blocked in JNI code up to 100 threads. Does that change any of the answers? This is perhaps a silly number, I'm just trying to understand if more resources are consumed by blocking in the JNI as opposed to blocking in Java.
    4) Do modern JVM's use one native thread per Java thread? If so, then I would guess there is really nothing special about blocking in native code.
    Motivation for query -- In my application I need to interface with legacy C++ code that blocks (mostly on socket and i/o selects). I'm not thrilled about native code, but if there are no serious side-effects to extended blocking, it may be a viable approach.

    1) Are there any negative side-effects to having one
    (or maybe a few) Java threads block for an extended
    period (e.g. hours) in native code? Naturally the
    thread would NOT be one of the "special" threads (such
    as the Swing event dispatcher, etc).As far as I know the native code is loaded dynamic when a thread will use it.
    So if the thread 1 needs the code written in the native.dll the thread 1 will use
    the first instance of native.dll. So let's say this is blocked.
    Then after 2 hours another thread called thread2 calls the native.dll code. Then
    java ask the OS to create another instance of the native.dll and so on.
    So now there are 2 threads and 2 instances of the dll in the memory.
    All these apply to the Win32 OSs.
    >
    2) Does the answer vary by platform? I'm interested
    in Win32, Linux and possibly Solaris (in that order).
    3) What if I scale the number of threads blocked in
    JNI code up to 100 threads. Does that change any of
    the answers? This is perhaps a silly number, I'm just
    trying to understand if more resources are consumed by
    blocking in the JNI as opposed to blocking in Java.
    If your machine could suffer 100 pure java threads then it is not a problem to be some of them JNI ones.
    4) Do modern JVM's use one native thread per Java
    thread? Yes. Exactly as far as I know and experienced.
    If so, then I would guess there is really
    nothing special about blocking in native code.Exactly.
    >
    >
    Motivation for query -- In my application I need to
    interface with legacy C++ code that blocks (mostly on
    socket and i/o selects). I'm not thrilled about
    native code, but if there are no serious side-effects
    to extended blocking, it may be a viable approach.Yes it is. That is actually why Native methods are existing for.

  • Can I swap the power supply on my iMac G5 without any unwanted side effects?

    Hi All,
    I'm new and have searched related posts, but have not found an answer to this exact question.
    I have a first generation US version iMac G5. The label says that the power supply is 100-120V. Can I swap the power supply using an internationally rated power supply (100-240V) from a later version iMac G5 without any unwanted side effects? Such as the iMac G5 ALS power supply?
    I live China and would prefer not to rely on an external power suppressor or convertor. I would prefer to plug and go.
    Thanks,
    SGP

    Try looking in xlr8yourmac.com for hints, also check out Jim Warholic's site.

  • �possible that the JNI side generates many instances of the native code?

    Hi guys,
    I asked this in a previous post but maybe with a bad constructed question.
    I have C code that generate data (particles) for one client (non multithreading). In my webapp Im gonna have many clients but changing the C side is not initially my best solution.
    When one client connects to the server ( calls the C code to generate data) it works ok, because I have only one client. When two or more clients connects to the server,
    the data generated by the C side is DIVIDED over all clients. So, I need 'n' replications of the C side, non one C side, this way my data structures in the C side will be replicated
    'n' times and could generate data for 'n' clients. Hope I have explained the right way.
    Please replies! :).

    1. Serialize the requests into the C code so that only one request is active. Save any state elsewhere. (Could be saved in java, could be saved in some C-side structure)Hi bschauwejava,
    I think my problem is not concurrency, saving the state in java will mean a lot of overload but its an option.
    Do you mean there is no way of having many instances of the C code ? this way I will have my state in each particular instance (one instance per client connected), and I could can forget about state.

  • Will killing pacman have any side effects?

    Hi recently while doing an upgrade with pacman, the download of a package will stop and I will not get any feedback anymore. So I leave it for a few hours but nothing happens so I decided to ^C which I know will kill pacman. What bad side effects should I expect from doing this? and is anyone else having a similar problem with pacman?

    shining wrote:
    dav7 wrote:
    moljac024 wrote:This is annoying, we had a topic about this. It seems that pacman just stops responding from time to time for some of us. Of course, there is no special way to reproduce it, so it's a tough bug.
    Maybe pacman should be modified to support an option (for pacman.conf) that causes pacman to log a TON of debug info to eg /var/log/pacman-debug.log, and those that experience the issue can try the setting out. And by "ton" I mean... every 2nd line in pacman being a debug_print() call (or whatever)
    Just an idea. I like ideas.
    You mean like pacman --debug ?
    To moljac024 : At which step does pacman stop responding? During download? You might have some network issues, unrelated to pacman.
    At least, I don't experience anything similar, and I am sure many other users as well.
    Yes, it just hangs during download. And at random times. And no, it's no network issue because as soon as I restart it, it continues downloading. A couple of times I've left my laptop downloading updates and went away doing other things only to return an hour or two later and see that it stopped 5 minutes after it started and had been hanging the whole time.
    Should I just run pacman with --debug always ? I guess I could do that.

  • Side-effects or negative sides of specific kind of connection

    First of all, I have to say that I don't have much experience in networking.
    I'm interested to know are there any specific side-effects or negative sides of connecting method I'm currently using.
    I have an ADSL modem/router Huawei HG510, which has 4 ethernet ports, locked by internet provider to provide internet connection on ports 1 and 4, IPTV on port 3, and port 2 reserved for VoIP. Close to this router I have AirPort Extreme (n-version) which I've connected to ADSL router in this way:
    - _IPTV lan (ethernet 2) port on ADSL router is connected to WAN port on AirPort_
    - _Internet connection is provided through ethernet 1 (LAN 1) port on ADSL router which is connected to LAN 1 port on AirPort_
    AirPort Extreme is configured as a bridge with manually assigned IP address with DNS set to IP address of ADSL router.
    DHCP is running on a ADSL router.
    AirPort Extreme provides 802.11g-only WDS network. In another room there is a WDS remote - AirPort Express (b/g model) which is connected to stereo, and also to IPTV STB by using ethernet cable.
    AirPort Express is also configured as a bridge with manually assigned IP address and DNS set to IP address of ADSL router. Two computers (one PC and one MacBook Pro) connect to this wireless network (sometimes I connect them to AirPort Extreme by cable) and they both have manually assigned IP addresses.
    So basically AirPort Extreme provides both Internet and IPTV streams.
    I don't have any special problems with this kind of connection, but I've noticed that sometimes when I reboot the system on MacBook Pro, internet connection is not recognized immediately, and network diagnostic commands such as - arp work with a long delay. This fixes by itself after some time, but I would like to know what cause it.
    btw wireless network is set on Multicast rate of 24Mbps
    Any comments and suggestions are appreciated.

    Is there a reason why you can't connect ethernet 1 (LAN 1) port on the router to the WAN port of the airport extreme base station? I'd have thought that might be better way for it to be networked to internet connection if going to act as bridge. networking internet connection and IPTV at same time may be not ideal situation for extreme base station network.
    Anyway, if I'm missing something then it's also possible that your network may just be a bit too technically complex for the extreme base station, it really is aimed to be plug and play and not that user configurable: it either works or it doesn't. If you have to have it as you describe above, and can't improve situation by altering settings present in the airport admin utility, then may want to look at other wireless bridges on the market.

  • Side effect of Service Pack for SAP XI 3.0

    Hi,
    Currently we are running on SP9, and want to upgrade to latest SP for XI 3.0 , At present my system is stable and mainly we are using XSLT/Message/Java mapping. Can you guys please tell me is there any possible side effect of upgradation so that we will take care of them.
    It will be nice if you can provide checklist also.

    Dear Gourav,
    Similar kind of situation we had, there was no issue,Infact there will be more functions.
    Regards
    Agasthuri Doss
    Message was edited by: Agasthuri Doss Baladandapani

  • Db2bak side effects on the database

    Dear All,
    I would like to know what is the impact / side effect of db2bak on the database?
    Does it lock the database while running?
    Moreover, if you can provide me with more ideas/ info about any other side effects would do me great.
    Regards,
    Scotty

    I am running a stored procedure that uses getXML. I would like to know how much memory its using up. I was told to increase the java pool, but it did not help with large query of getXML. What should I monitor for getXML?
    Thanks.

  • What are the non-obvious side-effects of using $psdefaultparametervalues.add("ft:wrap",$True) ?

    I'm thinking about dropping these two lines into my profile.ps1 script:
    $psdefaultparametervalues.add("ft:wrap",$True)
    $psdefaultparametervalues.add("ft:auto",$True)
    Are there any adverse side-effects that I will suffer after I do that?
    I know that I'll have to do explicit overrides to those switch values to Format-Table if I don't want those defaults.

    One thing I can think of is if you use -Property * to list everything, it has the potential to leave out columns if the properties are too long.
    Try this first:
    gci | Select -first 1 | FT *
    Then this:
    gci | Select -first 1 | FT * -auto -wrap
    Besides that , I can't really think of anything else; perhaps others can think of things.
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Hey guyz.. i wanna ask if i get an updated version from itunes when i plug my iPhone into the Pc, i get a letter tells me that there is an update for your iPhone ... i wanna ask is it safe to download ?? and does it make any side effects on longTerm using

    hey guyz.. i wanna ask if i get an updated version from itunes when i plug my iPhone into the Pc, i get a letter tells me that there is an update for your iPhone ... i wanna ask is it safe to download ?? and does it make any side effects on longTerm using ??

    It is safe to download if your phone is not jailbroken. Before you download it, however, take some precautions:
    Reboot your computer
    Disable your antivirus and firewall
    Connect the phone cable to a USB port directly on the computer, not a hub
    Before updating right click on the name of the phone in iTunes and choose "Backup"
    When you are given the choice choose "Download only", not "Download and Update"
    After the download completes successfully click the Update button to install it.
    Most of these steps are just being overly cautious, as most people ignore them and have no problems. But occasionally the extra steps save grief.

  • Using Field Blend plug-in, any side effects?

    Cutting an HDV show with lots of action. Camera may have had 'sharpen' mode set too high, but end result is that the action scenes show way too much of the 'interlace lines' in playback on an LCD screen. Distractingly so.
    I used the Field Blend plug-in from Joe's Filters on the whole show, and get a very smooth looking clean result. No interlace lines on LCD screen.
    But! What I'm wondering is: will this have a negative effect when I output the HDV Quicktime master to MPEG2 and DVD?
    Is there some side-effect one has to deal with when using the Field Blend plug-in?
    All ears, thank you,
    Ben

    Are there any side effects of munging two fields
    together? Yes. You are about halving your resolution.
    The show works fine on an NTSC monitor. But the client will be showing it on a lovely new laptop, and also projecting it in a large cinema theatre.
    The thing that puzzles me Patrick, is that I play both versions on a 23 inch Apple HD Cinema monitor and I cannot for the life of me see any difference, other than the 'blended' version is not full of interlace artefacting. I KNOW it's SUPPOSED to be less resolution. But I can't SEE any difference. Maybe on a 35 foot theatre screen?
    Maybe Joe is doing something special with his plug-in?
    B.

  • Are there any OSS notes side effects.

    Hello Everyone,
                            Can anyone tell me:
       Will there be any side effects if we implement OSS Notes in BW.
    Did anyone face this problem, i'm just asking you because we need to transfer a note from BW dev to BW prd, just wanted to be carefull about this and also
       Did anyone face any drawbacks after the implementation of the note?
       What if we apply the wrong note then how to rectify it? can any one suggest on this.please.
    Message was edited by:
            ram

    Hi,
    Advice : You should only apply notes which you have read, once applied to the SAP Dev system you should check (you should have a checklist of things to check) and systematically go through it to see that the OSS note hasn't made something else in the system not work. Once the checks have been carried out and it has solved the original bug that you had then only should you promote it to production.

  • How to minimise side effects of any note / Patch Application

    How can one know that what effect a note / Patch is going to have and what all transaction codes it will hit..
    For example i applied one note which seems to have activated a certain schema which was earlier commented out in the system. resulting in the printing of payslip with incorrect details.
    How can one minimize any side effects of any note applied in the system...kindly suggest.
    Regards,
    Ankush

    Dear All,
    The reason i ask this question on this forum is the fact that in the past few instances i have faced certain issues due to application of notes related to form 24Q (these are the oly notes we have applied)
    and the issues are coming in Payroll, in payslips and certain areas which i feel should remain unaffected by the note application...
    However i appreciate all he answers and also would like to urge SAP to maybe release atleast the standard Testing that should be done after a particular Note application. i do not know if this is a reasonable demand but it is always better to have it right from the horses mouth...
    Hope you agree to this........and will garner support for the same......
    Regards
    Ankush

  • Any side effects on JRE/JVM when setting Desktop Heap Size?

    In Win2003 we experience a limitation of about 70 java.exe's. By setting the Desktop Heap Size we can increase this limit to more than double. Link showing more info on Desktop Heap Size:
    http://blogs.msdn.com/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx
    Does this give any side effects to the running java.exe's?
    Has anyone experimented with this?

    Hi Bobo
    It seems to be a bit small. I have close the same configuration like you and set the
    maxMemory to 512 MB/server
    Regards Ruedi :-)
    Bob Krause schrieb:
    Hello,
    I have a customer that is running WLS 6.1 sp4 and they have set the JVM max memory
    value to 64M on a Sun Solaris box with over 6 meg of memory and 4 CPUs.
    We have an application on it that makes use of connection pooling, session objects,
    over 30+ stateless session beans, and has 100-200 users connected to the application
    for 4-8 hours at a time.
    Does this value of 64M make any sense??? This is the default out of the box setting
    that we have setup on our development PCs.
    Also as a side note, can any point me in the direction of any formulas for the
    calculation of this number and also the number of execute threads.
    Thank you,
    Bob

  • Is there any side effect despite in 'sharing' when I change the computername in os x 10.6

    Hi,
    I'm not sure about any side effect if I change my computer's name (currently like 'first name last name MacbookPro'), e.g will time machine have any trouble with that? Would like to change to a shorter name.
    Computer is in use since 2 years and everything works fine. Just tried to integrate sonos music system with my mac and have trouble sharing iTunes library with sonos. Therefore sonos support asked me to shorten the computers name and see if that helps.
    To me seems more sth like permission problem on one of the folders above iTunes. Is there any logfile I could check to find out about access to files which permission settings don't allow?
    Tia and kind regards
    Manu

    trimanu wrote:
    will time machine have any trouble with that?
    no.
    you can safely change your computer's name as often as you like.

Maybe you are looking for