НОВОЕ: OS/2 GURU - Вопросы и ответы ru · en · de · es · it · pt · cz · pl · fr

OS/2.GURU Library

Reviews / articles about OS/2 eComStation ArcaOS

Operating systems
ArcaOS, eComStation, IBM OS/2 Warp
eComStation myths 

Latest  
 
 
Blonde Guy

Reformat Утилита для форматирования USB флешек, USB винчестеров (для совместимости с OS/2)

 

(promo)

Unsorted

 

 

AD: ArcaOS 5.1 Russian LIP
Russian ARCAOS exists and it's available since the middle of 2017. All versions are supported: 5.1, 5.1.1.

eCo Software is able to maintain OS/2 LIP packages for any other language (German, Dutch, Brazilian Portuguese, Spanish, Sweden, etc)

My EMX program takes much CPU


TITLE: My EMX program takes much CPU

DATE: 2001-08-14 00:32:52

AUTHOR: nickk
Please use online translator
go to http://translate.google.com
and request the translation of http://ru.ecomstation./projects/reviews/index.php?id=5
to your language

Моя EMX программа кушает много CPU

Если вы скомпилировали программу-демон с помощью gcc и заметили, что она кушает слишком много CPU на общем уровне (смотреть надо не абсолютные, а относительные показатели, например, с помощью top) даже во время простоя, проверьте, используете ли вы функцию select. Если это так, попробуйте заменить ее на нижеследующую функцию:

int ibm_select( int *fds, int n_read, int n_write, int n_exept, long timeout);

int os2_select (int nfds, fd_set *readfds, fd_set *writefds,
             fd_set *exceptfds, struct timeval *timeout)
/* We are using the EMX select() call if non-socket handlers
   are presented in sets and IBM select() otherwise.
   EMX select() causes high CPU usage in polling loop.
*/
{
    fd_set *fds[3] = { readfds, writefds, exceptfds };
    int fd_os2[FD_SETSIZE * 3], fd_emx[FD_SETSIZE * 3];
    int n_fd[4], n = 0;
    int i, k, s;
    long ibmtimeout = -1;

    for(k = 0; k < 3; k++) {
	n_fd[k] = n;
	if(!fds[k])
	    continue;

	for(i = 0; i < nfds; i++) {
	    if(!fds[k]->fds_bits[i>>5]) {
		i += 31;
		continue;
	    }
	    if(!FD_ISSET(i, fds[k]))
		continue;
	    s = _getsockhandle(i);
	    if(s < 0) 
		return select(nfds, readfds, writefds, exceptfds, timeout);
	    else {
		fd_os2[n] = s;
		fd_emx[n++] = i;
	    }
        }
    }

    n_fd[3] = n;

    if (timeout) ibmtimeout = timeout->tv_usec/1000 + timeout->tv_sec*1000;
    s = ibm_select(fd_os2, n_fd[1]-n_fd[0], n_fd[2]-n_fd[1], n_fd[3]-n_fd[2],
			ibmtimeout);

    if(s == 0)			/* Timeout */
	return 0;
    if(s < 0) {			/* Error */
	if(sock_errno() == 10004)		/* SOCEINTR */
	    errno = EINTR;
	else
	    errno = EINVAL;
	return -1;
    }

    i = 0;
    for(k = 0; k < 3; k++) {
	n = n_fd[k+1];
	for( ; i < n; i++)
	    if(fd_os2[i] < 0) 
		FD_CLR(fd_emx[i], fds[k]);
    }
    return s;
}

Где функции ibm_select и sock_errno() берутся из so32dll.dll:

; ibmtcp.imp
; -------- so32dll entry points --------
ibm_select              so32dll   12 ?
sock_errno              so32dll   20 ?

Чтобы получить либу с этими функциями, запустите: emximp -o ibmtcp.a ibmtcp.imp.

Почему надо менять EMX'овый select на вышеприведенный, вкратце написано в комментарии к ней - "EMX select() causes high CPU usage in polling loop". Впрочем, если вы используете select только файловые хэндлы, то лучше ничего не меняйте - никакого выигрыша от этого не будет.

Для справки, данной функцией успешно пользуются последние и не очень последние OS/2 билды squid, bind, sshd, wget...

Сделаем EMX лучше ! :)

Автор статьи: nickk

Test the program:

Can I use social networks from eComStation? Can I manage my bank account from eCS? share your experience..

Komentarze:

eCo Software is a group of russian developers.
How to support eCo Software? (you can send us some computers. Maybe you don't use the device but it may be useful for the developers). We have the mailboxes in USA, Netherlands, China and Hong Kong.

 

Siberian OS/2

 


 

 

ArcaOS 5.1.1 - DOS works again

DOS virtual machine works again (it was working on Core 2 Duo, and didn't for i5). Install ArcaOS in UEFI mode to use DOS VM.

PNG icons on Desktop

eCo Software: it's a significant achievement that we have created PNG icons engine for OS/2 Desktop. and designed the set of system icons. In other words, we have modernized the external view of OS/2.

Now we can discuss how to attract new users.

// надо на ENG!!
Blonde Guy

Buy OS/2 application: PM Backup Suite (incremental data backup)

 
Every conference is important.

Warpstock Europe 2011

Interview with Mark Dodel (active user)

 

(C) OS2.GURU 2001 -- 2025