DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Notes and examples for multithreaded TTY drivers

Modifying the poll(D2oddi) routine

The poll(D2oddi) routine can be used to handle interrupts passed on a queue by the intr(D2oddi) routine if the intr( ) routine is not multithreaded. If you decide to structure your driver so that a majority of the processing occurs in the poll routine, make sure that you remember to use multiple locks where necessary to avoid contention for the same lock at clock interrupt time.

If your poll( ) routine executes instructions that should only be executed once per clock tick, you should make sure that this happens. In a multiprocessor environment (for example, five processors), the poll( ) routine could be called five times per tick. In such a case, the action that should only be executed once will be executed five times. The cur_cpu( ) routine allows you to check which is the current processor. cur_cpu returns 0 if it is executing on the base processor, 1 if it is on the first additional processor, 2 if on the second additional processor, and so forth.

It is important to check the interrupt's spl(D3oddi) level. A poll( ) routine is activated by a tick of the system clock, that can interrupt at spl5 level. At this level, other processes could be manipulating clist code, and so there is the possibility of corruption. Therefore you should check the spl level at which the poll( ) routine was activated; if the level is greater than or equal to level 5, you should return. The code illustrates this point:

   11  #define ATSPL (lev, spl)   ((spl) >= lev)
   12
   13  if (ATSPL (5, oldspl))
   14     return;
If your poll routine does not do any clist manipulation, you can omit the check.
© 2005 The SCO Group, Inc. All rights reserved.