Some atomic read/writes can be avoided since chunk_end has the same value of first during all the scheduling
function EXTRACT_SEQ
old_first <- first
chunk_begin <- MIN(chunk_end + chunk_size, last)
if chunk_begin > chunk_end then
first <- chunk_begin
if chunk_begin < last then ! Confirma se a extração é válida
tmp <- chunk_end
chunk_end <- chunk_first
chunk_first <- tmp
return TRUE
end if
first <- chunk_end ! Conflito: desfaz e trava a si próprio
end if
LOCK(self)
chunk_begin <- first
if chunk_begin < last then
first <- chunk_end <- last
end if
UNLOCK(self)
return chunk_begin < first
end function
Some atomic read/writes can be avoided since
chunk_endhas the same value offirstduring all the scheduling