Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Timers & Sockets

0.00/5 (No votes)
8 Apr 2005 1  
Control of timers, timings, offered services, and used services.

Sample Image

Introduction

BOS contains the functionality of the TIM and SOC sub-systems. Seventeen additional routines are provided to satisfy application program requirements in a C/C++ and VB environment. The praxis is that 150TIM+400SOC slots are enough for an application.

Background

Each slot may be set up to signal an event-flag, execute a function, or spin-off a thread; with or without a parameter. A slot is allocated a number (i.e., 1 to 550) on creation. Slots may be removed by slot-number.

Initialization is done when the first call to any relevant routine is made. A slot is set up using make_slot. A slot is destroyed using remove_slot. The BOS sub-system is de-initialized using reset. The user facilitates the actions by calling await_slot.

When a slot is signaled, its actions are performed, unless its action is �to return from await_slot� and we are not in await_slot. When we are, then it will.

A process is expected to set up its slot requirements from any of its threads and then some of these threads spend their time in await_slot. When a thread returns from await_slot, for other than a timeout reason, it will be because a signaled state that has no function or thread entry setup in the relevant slot group has occurred. Having actioned this signaled state, the thread should recall await_slot. Perhaps a common usage will have all slot entries with a function or thread entry point so that the only return from await_slot will be for a timeout reason.

The 'await' and nine 'make' calls take a group number. This allows sub-sets of the collection of slots to be waited on, perhaps by different threads.

Using the code

VC 6.0 projects:

  • Place the BOSDLL.dll in a directory on your path variable.
  • Add the library BOSDLL.lib to the project resources.
  • Add the modules BOScalls.h, SOCcalls.h and TIMcalls.h to the project.
  • Use the routines therein.

VB 6.0 projects:

  • Register the BOSDLL.dll with regsvr32.
  • Add the modules BOSDLL.bas, SOCDLL.bas and TIMDLL.bas to the project.
  • Use the public routines therein.
//

// Source code to produce the above console screen

// is to be found in the 1st of the 3 demo C/C++ projects.

//

History

  • 3.4 - BOS_Src.cpp - Comment/Logging maintenance.
  • 3.3 - For C/C++ only users, a static library can be built using the workspace and the project files provided.
  • 3.2 - Server-side 'select' timeout is reduced from 50 to 1 millisecond. This allows faster transfer, though one's machine will get busier.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here