Fix a race in access to manager->tasks in taskmgr

Make taskmgr->mode and boolean state flags (exclusive, paused, exiting) atomic.
43 jobs for !1396 with wpk-fix-taskmgr-tsan-issues in 23 minutes and 44 seconds (queued for 5 seconds)
detached
Status Job ID Name Coverage
  Precheck
passed #159906
amd64 linux
🐞:sid:amd64

00:00:38

passed #159905
amd64 linux
misc:sid:amd64

00:00:18

 
  Build
passed #159916
amd64 linux
asan:sid:amd64

00:01:14

passed #159917
amd64 linux
clang:stretch:amd64

00:02:19

passed #159918
i386 linux
clang:stretch:i386

00:01:29

passed #159907
amd64 linux
docs:sid:amd64

00:00:52

passed #159915
amd64 linux
gcc:bionic:amd64

00:01:21

passed #159908
amd64 linux
gcc:centos6:amd64

00:01:58

passed #159909
amd64 linux
gcc:centos7:amd64

00:01:51

passed #159910
amd64 linux
gcc:jessie:amd64

00:01:57

passed #159912
amd64 linux
gcc:sid:amd64

00:01:12

passed #159913
i386 linux
gcc:sid:i386

00:01:14

passed #159911
amd64 linux
gcc:stretch:amd64

00:02:41

passed #159914
amd64 linux
gcc:xenial:amd64

00:01:23

passed #159920
amd64 linux
noassert:sid:amd64

00:01:06

passed #159919
amd64 linux
pkcs11:sid:amd64

00:02:39

 
  Test
passed #159929
amd64 linux
install:gcc:sid:amd64

00:02:24

passed #159938
amd64 linux
system:asan:sid:amd64

00:08:05

passed #159945
linux amd64
system:gcc:bionic:amd64

00:06:15

passed #159987
amd64 linux
system:gcc:centos6:amd64

00:06:55

passed #159923
amd64 linux
system:gcc:centos7:amd64

00:07:00

passed #159925
amd64 linux
system:gcc:jessie:amd64

00:07:00

passed #159930
amd64 linux
system:gcc:sid:amd64

00:06:41

passed #159932
i386 linux
system:gcc:sid:i386

00:07:03

passed #159927
amd64 linux
system:gcc:stretch:amd64

00:06:16

passed #159934
amd64 linux
system:gcc:xenial:amd64

00:06:11

passed #159943
amd64 linux
system:noassert:sid:amd64

00:06:42

passed #159941
amd64 linux
system:pkcs11:sid:amd64

00:07:12

passed #159939
amd64 linux
unit:asan:sid:amd64

00:01:32

passed #159940
amd64 linux
unit:clang:stretch:amd64

00:00:49

passed #159937
amd64 linux
unit:gcc:bionic:amd64

00:00:45

passed #159922
amd64 linux
unit:gcc:centos6:amd64

00:00:44

passed #159924
amd64 linux
unit:gcc:centos7:amd64

00:00:46

passed #159926
amd64 linux
unit:gcc:jessie:amd64

00:00:31

passed #159931
amd64 linux
unit:gcc:sid:amd64

00:00:48

passed #159933
i386 linux
unit:gcc:sid:i386

00:00:45

passed #159928
amd64 linux
unit:gcc:stretch:amd64

00:00:51

passed #159935
amd64 linux
unit:gcc:xenial:amd64

00:00:49

passed #159944
amd64 linux
unit:noassert:sid:amd64

00:00:44

passed #159942
amd64 linux
unit:pkcs11:sid:amd64

00:00:44

failed #159936
amd64 linux
system:gcc:bionic:amd64

00:07:08

failed #159921
amd64 linux
system:gcc:centos6:amd64

00:07:10

failed #159946
linux amd64
system:gcc:centos6:amd64

00:06:38