Click here to Skip to main content
15,867,704 members
Articles / Desktop Programming / MFC
Article

Timers & Sockets

Rate me:
Please Sign up or sign in to vote.
4.10/5 (5 votes)
7 Apr 20052 min read 43.6K   3.7K   22   3
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


Written By
Web Developer
United Kingdom United Kingdom
BSc (St.Andrews(1963-67))
MSCE
Systems Programmer 39+yrs
Married to first wife 35yrs & counting, four grown-up children
Religious opinions similar to MelG's
It is not the gnosis, but the praxis must be the fruit. (Aristotle)

Comments and Discussions

 
General[Message Deleted] Pin
it.ragester2-Apr-09 21:53
it.ragester2-Apr-09 21:53 
GeneralMarried to first wife... Pin
George L. Jackson20-Apr-04 10:34
George L. Jackson20-Apr-04 10:34 
"Married to first wife 32yrs & counting, four grown-up children"

So, does this mean you are presently married to more than one wife? Smile | :)

"Married to my first and only wife for 32 years ..."

GeneralRe: Married to first wife... Pin
Lymington28-Apr-04 12:42
Lymington28-Apr-04 12:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.