.


:




:

































 

 

 

 


.

 

 

 

1

: " "

 

 

926

..

..

 

 

  1. :

. :

- , ;

- ;

- ;

.

  1. :

.

  1. :

- , . . open, pipe, creat fcntl. . , fork. , fcntl, dup dup2.

, u_block . open creat, . fork . .

( ) . u_block . : . :

 

struct ufd

{

struct file *fp;

int flags;

}u_ufd[OPEN_MAX]

 

fcntl FD_CLOEXEC . dup . fork .

. - , , (O_RDONLY, O_WRONLY O_RDWR).

, , . /etc/security/limits 2000 ( ). ulimit setrlimit. OPEN_MAX.

0, 1 2. :

0 .

1 .

2 .

. , 0 , 1 2 . .

- < ( ) > ( ), . , :

prog < FileX > FileY

0 1 . 0 FileX, 1 - FileY. 2 . , 0 , 1 2 - . , , .

 

4. :

 

sseg segment para stack 'stack'

dw 80 dup(?)

sseg ends

;----------------------------------------------------------

dseg segment 'data'

strout1 db 'vvedit ryadok',13,10,'$'

strout2 db 'symvoliv v ryadku: ','$'

strout3 db '------[vyvid informacii]------',13,10,'$'

crlf db 13,10,'$'

buff db 80,?, 80 DUP(' ')

buflen equ 80

stdout equ 1

filename db 'file1.txt',0

err1 db 'oshibka 3Ch',13,10,'$'

handle dw?

bytesinstr db 3 DUP(?),'$'

dseg ends

; ---------------------------------------------------------

cseg segment 'code'

assume cs:cseg, ds:dseg, ss:sseg, es:dseg

start: mov ax,dseg

mov ds,ax

mov es,ax

 

 

mov ah,3ch;

mov cx,0;

mov dx,offset filename;

int 21h

mov handle,ax;

jnc inputstr; CF

mov ah,9

lea dx,err1;

int 21h

jmp endprg

inputstr:;

mov ah,9

lea dx,strout1;

int 21h

mov ah,0ah;

lea dx,buff;

int 21h

mov bh,0

mov bl,byte ptr [buff+1]; BL

cmp bl,0;

je closehndl;

add bl,offset buff+2

mov byte ptr[bx],' '; CR

mov ah,9

lea dx,crlf;

int 21h

fop1:;

mov ah,40h;

mov bx,handle;

mov cx,buflen;

mov dx,offset buff+2;

int 21h

 

mov al,' ';20h;

mov di,offset buff+2;

mov cx,buflen;

cld; ( DF)

rep stosb;

 

jmp inputstr;

 

closehndl:;

mov ah,3eh;

mov bx,handle;

int 21h

 

mov ah,9

lea dx,crlf

int 21h

mov ah,9

lea dx,strout3

int 21h

call ReadFile;

 

endprg:

mov ah,4Ch; dos

int 21h

 

;

ReadFile proc near

mov ah,3Dh;

mov al,2; /

mov dx,offset filename

int 21h

mov handle,ax;

 

readrec:

mov ah,3fh;

mov bx,handle;

mov cx,buflen;

mov dx,offset buff+2;

int 21h

cmp ax,0

je closehndl1; 0

mov cx,ax;

 

mov ah,40h;

mov bx,stdout; (CON)

mov dx,offset buff+2; ,

int 21h

mov ah,40h

mov bx,stdout

mov cx,2

mov dx,offset crlf;

int 21h

call Variant4;

jmp readrec;

 

closehndl1:;

mov ah,3eh;

mov bx,handle;

int 21h

 

ret

ReadFile endp

 

;

Variant4 proc near

mov cx,buflen

mov di,offset buff+2

mov ax,0

calcstr:

cmp byte ptr[di],' ';

je contlp

inc al;

contlp:

inc di;

loop calcstr; CX(CX=CX-1)

mov byte ptr[bytesinstr],' ';

mov byte ptr[bytesinstr+1],' ';

mov byte ptr[bytesinstr+2],' ';

mov bx,offset bytesinstr+2

call numstrin;

mov ah,9

lea dx,strout2

int 21h

mov ah,9

lea dx,bytesinstr;

int 21h

mov ah,9

lea dx,crlf

int 21h

ret

Variant4 endp

 

; :

; ---------------------------

; : AX - , BX -

numstrin proc near

mov dl,10;

contdiv:

;

div dl; AX DL

; AH, - AL

mov byte ptr [bx],ah

add byte ptr [bx],30h

dec bx;

cbw;

cmp al,0;

ja contdiv

ret

numstrin endp

 

 

cseg ends

end start

 

 

  1. :

. :

, , . .



<== | ==>
. | 8 I:
:


: 2015-10-01; !; : 280 |


:

:

, , .
==> ...

1688 - | 1360 -


© 2015-2024 lektsii.org - -

: 0.025 .