• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OS context switch

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scenario:
Assume a scenario where there are a large number of threads waiting for CPU time. The OS is serving a thread which has established a socket connection with a remote client. The remote client has started transferring a large file through the connection.
Question:
If the time required to transfer the file through the socket is longer than the context-switch time of the OS (pre-emptive scheduling) like Windows, will the OS do a context-switch??? If it does, what happens to the REMOTE client which is in the middle of transferring data??? Will there be any data loss??
Thanks
Jawahar
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the time required to transfer the file through the socket is longer than the context-switch time of the OS (pre-emptive scheduling) like Windows, will the OS do a context-switch???
Yes, probably. I suspct that even with preemtive scheduling, there's a certain atomicity of actions, and thread management can't or won't cut things off too abruptly. When a tread is pre-emted, it must be able to save its state well enough that it can resume later without ill effects (other than a slight delay).
If it does, what happens to the REMOTE client which is in the middle of transferring data??? Will there be any data loss??
There shouldn't be any data loss - this is fairly standard usage of threads, I have to assume either the OS or the JVM is designed to handle it, or they wouldn't be able to claim to have implemented a JVM on that OS. Since a JVM is required to bea able to implement threads according to the JLS and JVM specs, which don't allow for threads which just randomly drop data. The remote client may observe some pauses in transmission of data, but that's normal - the client doesn't know or care whether delays are caused by something on the server, or in the network. It just waits until it has recieved enough data to process, then it processes the data. Usually there's a loop where it waits for an EOF or other signal (depending what protocol you're using).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic